forked from micronaut-projects/micronaut-core
-
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.
Normalization of bean class names for more correct logs
Fixed micronaut-projects#11320
- Loading branch information
Showing
4 changed files
with
47 additions
and
8 deletions.
There are no files selected for viewing
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
35 changes: 35 additions & 0 deletions
35
inject/src/main/java/io/micronaut/context/MessageUtils.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,35 @@ | ||
package io.micronaut.context; | ||
|
||
/** | ||
* @since 4.8.0 | ||
*/ | ||
public final class MessageUtils { | ||
|
||
private static final String POSTFIX_BEAN_DEFINITION_REFERENCE = "$Definition$Intercepted$Definition$Reference"; | ||
private static final String POSTFIX_BEAN_DEFINITION = "$Definition$Intercepted$Definition"; | ||
private static final String POSTFIX_BEAN_METHOD_DEFINITION = "$Definition$Intercepted"; | ||
|
||
private MessageUtils() { | ||
} | ||
|
||
/** | ||
* Normalization bean class names for logs. | ||
* | ||
* @param typeString bean class name | ||
* | ||
* @return normalized bean class name | ||
*/ | ||
public static String normalizeBeanClassName(String typeString) { | ||
if (typeString.startsWith("$")) { | ||
typeString = typeString.substring(1); | ||
} | ||
if (typeString.endsWith(POSTFIX_BEAN_DEFINITION_REFERENCE)) { | ||
typeString = typeString.substring(0, typeString.indexOf(POSTFIX_BEAN_DEFINITION_REFERENCE)); | ||
} else if (typeString.endsWith(POSTFIX_BEAN_DEFINITION)) { | ||
typeString = typeString.substring(0, typeString.indexOf(POSTFIX_BEAN_DEFINITION)); | ||
} else if (typeString.endsWith(POSTFIX_BEAN_METHOD_DEFINITION)) { | ||
typeString = typeString.substring(0, typeString.indexOf(POSTFIX_BEAN_METHOD_DEFINITION)); | ||
} | ||
return typeString; | ||
} | ||
} |
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