Skip to content

Commit

Permalink
Merge pull request #3583 from ebean-orm/feature/revert-3541-3582
Browse files Browse the repository at this point in the history
[querybean-generator] #3582 - Revert #3541 "FilerException trying to write EntityClassRegister with Quarkus dev mode / hot reload "
  • Loading branch information
rbygrave authored Mar 3, 2025
2 parents b4ff574 + 64f01f0 commit 80c3501
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.FilerException;
import javax.annotation.processing.FilerException;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.SourceVersion;
Expand All @@ -20,6 +21,8 @@ public class Processor extends AbstractProcessor implements Constants {
private static final String KAPT_KOTLIN_GENERATED_OPTION = "kapt.kotlin.generated";

private ProcessingContext processingContext;
private SimpleModuleInfoWriter moduleWriter;
private boolean initModuleWriter;

public Processor() {
}
Expand Down Expand Up @@ -60,6 +63,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
int count = processEntities(roundEnv);
processOthers(roundEnv);
final int loaded = processingContext.complete();
initModuleInfoBean();
if (roundEnv.processingOver()) {
writeModuleInfoBean();
}
Expand Down Expand Up @@ -96,11 +100,27 @@ private void processOthers(RoundEnvironment roundEnv, TypeElement otherType) {
}
}

private void writeModuleInfoBean() {
private void initModuleInfoBean() {
try {
new SimpleModuleInfoWriter(processingContext).write();
if (!initModuleWriter) {
moduleWriter = new SimpleModuleInfoWriter(processingContext);
}
} catch (FilerException e) {
processingContext.logWarn(null, "FilerException trying to write EntityClassRegister: " + e);
processingContext.logWarn(null, "FilerException trying to write EntityClassRegister error: " + e);
} catch (Throwable e) {
processingContext.logError(null, "Failed to initialise EntityClassRegister error:" + e + " stack:" + Arrays.toString(e.getStackTrace()));
} finally {
initModuleWriter = true;
}
}

private void writeModuleInfoBean() {
try {
if (moduleWriter == null) {
processingContext.logNote(null, "EntityClassRegister skipped");
} else {
moduleWriter.write();
}
} catch (Throwable e) {
processingContext.logError(null, "Failed to write EntityClassRegister error:" + e + " stack:" + Arrays.toString(e.getStackTrace()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
public class Processor extends AbstractProcessor implements Constants {

private ProcessingContext processingContext;
private SimpleModuleInfoWriter moduleWriter;
private boolean initModuleWriter;

public Processor() {
}
Expand Down Expand Up @@ -49,6 +51,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
int count = processEntities(roundEnv);
processOthers(roundEnv);
final int loaded = processingContext.complete();
initModuleInfoBean();
if (roundEnv.processingOver()) {
writeModuleInfoBean();
}
Expand Down Expand Up @@ -85,11 +88,27 @@ private void processOthers(RoundEnvironment roundEnv, TypeElement otherType) {
}
}

private void writeModuleInfoBean() {
private void initModuleInfoBean() {
try {
new SimpleModuleInfoWriter(processingContext).write();
if (!initModuleWriter) {
moduleWriter = new SimpleModuleInfoWriter(processingContext);
}
} catch (FilerException e) {
processingContext.logWarn(null, "FilerException trying to write EntityClassRegister: " + e);
processingContext.logWarn(null, "FilerException trying to write EntityClassRegister error: " + e);
} catch (Throwable e) {
processingContext.logError(null, "Failed to initialise EntityClassRegister error:" + e + " stack:" + Arrays.toString(e.getStackTrace()));
} finally {
initModuleWriter = true;
}
}

private void writeModuleInfoBean() {
try {
if (moduleWriter == null) {
processingContext.logNote(null, "EntityClassRegister skipped");
} else {
moduleWriter.write();
}
} catch (Throwable e) {
processingContext.logError(null, "Failed to write EntityClassRegister error:" + e + " stack:" + Arrays.toString(e.getStackTrace()));
}
Expand Down

0 comments on commit 80c3501

Please sign in to comment.