@@ -39,6 +39,14 @@ public final class WebMvcTags {
3939
4040 private static final Tag URI_REDIRECTION = Tag .of ("uri" , "REDIRECTION" );
4141
42+ private static final Tag URI_UNKNOWN = Tag .of ("uri" , "UNKNOWN" );
43+
44+ private static final Tag EXCEPTION_NONE = Tag .of ("exception" , "None" );
45+
46+ private static final Tag STATUS_UNKNOWN = Tag .of ("status" , "UNKNOWN" );
47+
48+ private static final Tag METHOD_UNKNOWN = Tag .of ("method" , "UNKNOWN" );
49+
4250 private WebMvcTags () {
4351 }
4452
@@ -50,9 +58,7 @@ private WebMvcTags() {
5058 * @return the method tag whose value is a capitalized method (e.g. GET).
5159 */
5260 public static Tag method (@ Nullable HttpServletRequest request ) {
53- return request == null ?
54- Tag .of ("method" , "UNKNOWN" ) :
55- Tag .of ("method" , request .getMethod ());
61+ return request == null ? METHOD_UNKNOWN : Tag .of ("method" , request .getMethod ());
5662 }
5763
5864 /**
@@ -62,7 +68,7 @@ public static Tag method(@Nullable HttpServletRequest request) {
6268 * @return the status tag derived from the status of the response
6369 */
6470 public static Tag status (@ Nullable HttpServletResponse response ) {
65- return response == null ? Tag . of ( "status" , "UNKNOWN" ) : Tag .of ("status" , (( Integer ) response .getStatus ()). toString ( ));
71+ return response == null ? STATUS_UNKNOWN : Tag .of ("status" , Integer . toString ( response .getStatus ()));
6672 }
6773
6874 /**
@@ -92,7 +98,7 @@ public static Tag uri(@Nullable HttpServletRequest request, @Nullable HttpServle
9298 String pathInfo = getPathInfo (request );
9399 return Tag .of ("uri" , pathInfo .isEmpty () ? "root" : pathInfo );
94100 }
95- return Tag . of ( "uri" , "UNKNOWN" ) ;
101+ return URI_UNKNOWN ;
96102 }
97103
98104 @ Nullable
@@ -125,8 +131,6 @@ private static String getPathInfo(HttpServletRequest request) {
125131 * @return the exception tag derived from the exception
126132 */
127133 public static Tag exception (@ Nullable Throwable exception ) {
128- return exception == null ?
129- Tag .of ("exception" , "None" ) :
130- Tag .of ("exception" , exception .getClass ().getSimpleName ());
134+ return exception == null ? EXCEPTION_NONE : Tag .of ("exception" , exception .getClass ().getSimpleName ());
131135 }
132136}
0 commit comments