forked from spring-projects/spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add exception and failure analyzer for missing AOT initializer
- Loading branch information
1 parent
90b1c18
commit 3c935c9
Showing
4 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...t/spring-boot/src/main/java/org/springframework/boot/AotInitializerNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2012-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.boot; | ||
|
||
/** | ||
* Thrown when the AOT initializer couldn't be found. | ||
* @author Moritz Halbritter | ||
*/ | ||
class AotInitializerNotFoundException extends RuntimeException { | ||
private final Class<?> mainClass; | ||
|
||
private final String initializerClassName; | ||
|
||
AotInitializerNotFoundException(Class<?> mainClass, String initializerClassName) { | ||
this.mainClass = mainClass; | ||
this.initializerClassName = initializerClassName; | ||
} | ||
|
||
Class<?> getMainClass() { | ||
return this.mainClass; | ||
} | ||
|
||
String getInitializerClassName() { | ||
return this.initializerClassName; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...ng-boot/src/main/java/org/springframework/boot/AotInitializerNotFoundFailureAnalyzer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2012-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.boot; | ||
|
||
import org.springframework.boot.diagnostics.AbstractFailureAnalyzer; | ||
import org.springframework.boot.diagnostics.FailureAnalysis; | ||
|
||
/** | ||
* An {@link AbstractFailureAnalyzer} that performs analysis of failures caused by a | ||
* {@link AotInitializerNotFoundException}. | ||
* | ||
* @author Moritz Halbritter | ||
*/ | ||
class AotInitializerNotFoundFailureAnalyzer extends AbstractFailureAnalyzer<AotInitializerNotFoundException> { | ||
@Override | ||
protected FailureAnalysis analyze(Throwable rootFailure, AotInitializerNotFoundException cause) { | ||
return new FailureAnalysis("Startup with AOT mode enabled failed: AOT initializer %s could not be found".formatted(cause.getInitializerClassName()), | ||
"Consider the following:\n" | ||
+ "\tDid you build the application with enabled AOT processing?\n" | ||
+ "\tIs the main class %s correct?\n".formatted(cause.getMainClass().getName()) | ||
+ "\tIf you want to run the application in regular mode, remove the system property 'spring.aot.enabled'", | ||
cause); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters