File tree Expand file tree Collapse file tree
src/main/java/com/hivemq/extension/sdk/api/services Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6262 */
6363public class Services {
6464
65- private static final String NO_ACCESS_MESSAGE =
66- "Static class Services cannot be called from a thread \" %s\" which" +
67- " does not have a HiveMQ extension classloader as its context classloader." ;
65+ private static final @ NotNull String NO_ACCESS_MESSAGE = "Only HiveMQ Extensions can access Services." ;
6866
6967 //this map is filled by HiveMQ with implementations for all services
7068 @ SuppressWarnings ("MismatchedQueryAndUpdateOfCollection" )
@@ -169,17 +167,18 @@ public class Services {
169167 private static <T > @ NotNull T getClassObject (final @ NotNull Class <T > clazz ) {
170168
171169 if (services == null ) {
172- throw new RuntimeException (String . format ( NO_ACCESS_MESSAGE , Thread . currentThread (). getName ()) );
170+ throw new RuntimeException (NO_ACCESS_MESSAGE );
173171 }
174172
175173 final Object object = services .get (clazz .getCanonicalName ());
176174 if (object == null ) {
177175 //don't cache this exception to keep the stacktrace, this is not expected to happen very often
178- throw new RuntimeException (String . format ( NO_ACCESS_MESSAGE , Thread . currentThread (). getName ()) );
176+ throw new RuntimeException (NO_ACCESS_MESSAGE );
179177 }
180178 if (clazz .isInstance (object )) {
179+ //noinspection unchecked
181180 return (T ) object ;
182181 }
183- throw new RuntimeException (String . format ( NO_ACCESS_MESSAGE , Thread . currentThread (). getName ()) );
182+ throw new RuntimeException (NO_ACCESS_MESSAGE );
184183 }
185184}
Original file line number Diff line number Diff line change 4444 */
4545public class Builders {
4646
47- private static final String NO_ACCESS_MESSAGE =
48- "Static class Builders cannot be called from a thread \" %s\" which" +
49- " does not have a HiveMQ extension classloader as its context classloader." ;
47+ private static final @ NotNull String NO_ACCESS_MESSAGE = "Only HiveMQ Extensions can access Builders." ;
5048
5149 //this map is filled by HiveMQ with implementations for all builders
5250 @ SuppressWarnings ("MismatchedQueryAndUpdateOfCollection" )
@@ -95,13 +93,13 @@ public class Builders {
9593 private static <T > @ NotNull Supplier <T > getClassSupplier (final @ NotNull Class <T > clazz ) {
9694
9795 if (builders == null ) {
98- throw new RuntimeException (String . format ( NO_ACCESS_MESSAGE , Thread . currentThread (). getName ()) );
96+ throw new RuntimeException (NO_ACCESS_MESSAGE );
9997 }
10098
10199 final Supplier <Object > objectSupplier = builders .get (clazz .getCanonicalName ());
102100 if (objectSupplier == null ) {
103101 //don't cache this exception to keep the stacktrace, this is not expected to happen very often
104- throw new RuntimeException (String . format ( NO_ACCESS_MESSAGE , Thread . currentThread (). getName ()) );
102+ throw new RuntimeException (NO_ACCESS_MESSAGE );
105103 }
106104 //noinspection unchecked: HiveMQ takes care of placing the right supplier in the map
107105 return (Supplier <T >) objectSupplier ;
You can’t perform that action at this time.
0 commit comments