Skip to content

Commit

Permalink
[querybean-generator] FilerException trying to write EntityClassRegis…
Browse files Browse the repository at this point in the history
…ter with Quarkus dev mode / hot reload #3541

Drop to log at WARN level when we catch FilerException such that Quarkus dev mode / hot reload works
  • Loading branch information
rbygrave committed Jan 16, 2025
1 parent 723a12f commit 69c2530
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,10 @@ void logError(Element e, String msg, Object... args) {
messager.printMessage(Diagnostic.Kind.ERROR, String.format(msg, args), e);
}

/**
* Log a info message.
*/
void logWarn(String msg, Object... args) {
messager.printMessage(Diagnostic.Kind.WARNING, String.format(msg, args));
}

void logNote(String msg, Object... args) {
messager.printMessage(Diagnostic.Kind.NOTE, String.format(msg, args));
}
Expand Down Expand Up @@ -559,7 +560,6 @@ String loadMetaInfServices() {
} catch (FilerException e) {
logNote(null, "FilerException reading services file: " + e.getMessage());
} catch (Exception e) {
e.printStackTrace();
logError(null, "Error reading services file: " + e.getMessage());
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ public class Processor extends AbstractProcessor implements Constants {
private static final String KAPT_KOTLIN_GENERATED_OPTION = "kapt.kotlin.generated";

private ProcessingContext processingContext;
private SimpleModuleInfoWriter moduleWriter;

public Processor() {
}

@Override
public Set<String> getSupportedOptions() {

Set<String> options = new LinkedHashSet<>();
options.add(KAPT_KOTLIN_GENERATED_OPTION);
options.add(GENERATE_KOTLIN_CODE_OPTION);
Expand Down Expand Up @@ -61,7 +59,6 @@ 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 @@ -98,26 +95,12 @@ private void processOthers(RoundEnvironment roundEnv, TypeElement otherType) {
}
}

private void initModuleInfoBean() {
try {
if (moduleWriter == null) {
moduleWriter = new SimpleModuleInfoWriter(processingContext);
}
} catch (Throwable e) {
e.printStackTrace();
processingContext.logError(null, "Failed to initialise EntityClassRegister error:" + e + " stack:" + Arrays.toString(e.getStackTrace()));
}
}

private void writeModuleInfoBean() {
try {
if (moduleWriter == null) {
processingContext.logError(null, "EntityClassRegister was not initialised and not written");
} else {
moduleWriter.write();
}
new SimpleModuleInfoWriter(processingContext).write();
} catch (FilerException e) {
processingContext.logWarn(null, "FilerException trying to write EntityClassRegister error: " + e);
} catch (Throwable e) {
e.printStackTrace();
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 @@ -50,7 +50,6 @@ private void writeServicesFile() {
}

} catch (IOException e) {
e.printStackTrace();
processingContext.logError(null, "Failed to write services file " + e.getMessage());
}
}
Expand All @@ -70,7 +69,6 @@ private void writeManifestFile() {
}

} catch (IOException e) {
e.printStackTrace();
processingContext.logError(null, "Failed to write services file " + e.getMessage());
}
}
Expand Down
3 changes: 2 additions & 1 deletion querybean-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
<version>14.8.1</version>
</parent>

<version>14.8.2-RC2</version>
<name>querybean generator</name>
<description>Querybean generator</description>
<artifactId>querybean-generator</artifactId>
<description>Querybean generator</description>

<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ void logError(Element e, String msg, Object... args) {
messager.printMessage(Diagnostic.Kind.ERROR, String.format(msg, args), e);
}

void logWarn(String msg, Object... args) {
messager.printMessage(Diagnostic.Kind.WARNING, String.format(msg, args));
}

void logNote(String msg, Object... args) {
messager.printMessage(Diagnostic.Kind.NOTE, String.format(msg, args));
}
Expand Down Expand Up @@ -549,7 +553,6 @@ String loadMetaInfServices() {
} catch (FilerException e) {
logNote(null, "FilerException reading services file: " + e.getMessage());
} catch (Exception e) {
e.printStackTrace();
logError(null, "Error reading services file: " + e.getMessage());
}
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.ebean.querybean.generator;

import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.FilerException;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.SourceVersion;
Expand All @@ -16,7 +17,6 @@
public class Processor extends AbstractProcessor implements Constants {

private ProcessingContext processingContext;
private SimpleModuleInfoWriter moduleWriter;

public Processor() {
}
Expand Down Expand Up @@ -49,7 +49,6 @@ 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 @@ -86,26 +85,12 @@ private void processOthers(RoundEnvironment roundEnv, TypeElement otherType) {
}
}

private void initModuleInfoBean() {
try {
if (moduleWriter == null) {
moduleWriter = new SimpleModuleInfoWriter(processingContext);
}
} catch (Throwable e) {
e.printStackTrace();
processingContext.logError(null, "Failed to initialise EntityClassRegister error:" + e + " stack:" + Arrays.toString(e.getStackTrace()));
}
}

private void writeModuleInfoBean() {
try {
if (moduleWriter == null) {
processingContext.logError(null, "EntityClassRegister was not initialised and not written");
} else {
moduleWriter.write();
}
new SimpleModuleInfoWriter(processingContext).write();
} catch (FilerException e) {
processingContext.logWarn(null, "FilerException trying to write EntityClassRegister error: " + e);
} catch (Throwable e) {
e.printStackTrace();
processingContext.logError(null, "Failed to write EntityClassRegister error:" + e + " stack:" + Arrays.toString(e.getStackTrace()));
}
}
Expand All @@ -115,7 +100,6 @@ private void generateQueryBeans(Element element) {
SimpleQueryBeanWriter beanWriter = new SimpleQueryBeanWriter((TypeElement) element, processingContext);
beanWriter.writeRootBean();
} catch (Throwable e) {
e.printStackTrace();
processingContext.logError(element, "Error generating query beans: " + e);
}
}
Expand Down

0 comments on commit 69c2530

Please sign in to comment.