@@ -192,7 +192,7 @@ private void neverEntitled(Class<?> callerClass, Supplier<String> operationDescr
192192 return ;
193193 }
194194
195- throw new NotEntitledException (
195+ notEntitled (
196196 Strings .format (
197197 "Not entitled: component [%s], module [%s], class [%s], operation [%s]" ,
198198 getEntitlements (requestingClass ).componentName (),
@@ -251,7 +251,7 @@ public void checkFileRead(Class<?> callerClass, Path path) {
251251
252252 ModuleEntitlements entitlements = getEntitlements (requestingClass );
253253 if (entitlements .fileAccess ().canRead (path ) == false ) {
254- throw new NotEntitledException (
254+ notEntitled (
255255 Strings .format (
256256 "Not entitled: component [%s], module [%s], class [%s], entitlement [file], operation [read], path [%s]" ,
257257 entitlements .componentName (),
@@ -276,7 +276,7 @@ public void checkFileWrite(Class<?> callerClass, Path path) {
276276
277277 ModuleEntitlements entitlements = getEntitlements (requestingClass );
278278 if (entitlements .fileAccess ().canWrite (path ) == false ) {
279- throw new NotEntitledException (
279+ notEntitled (
280280 Strings .format (
281281 "Not entitled: component [%s], module [%s], class [%s], entitlement [file], operation [write], path [%s]" ,
282282 entitlements .componentName (),
@@ -325,7 +325,7 @@ private static void checkFlagEntitlement(
325325 Class <?> requestingClass
326326 ) {
327327 if (classEntitlements .hasEntitlement (entitlementClass ) == false ) {
328- throw new NotEntitledException (
328+ notEntitled (
329329 Strings .format (
330330 "Not entitled: component [%s], module [%s], class [%s], entitlement [%s]" ,
331331 classEntitlements .componentName (),
@@ -365,7 +365,7 @@ public void checkWriteProperty(Class<?> callerClass, String property) {
365365 );
366366 return ;
367367 }
368- throw new NotEntitledException (
368+ notEntitled (
369369 Strings .format (
370370 "Not entitled: component [%s], module [%s], class [%s], entitlement [write_system_properties], property [%s]" ,
371371 entitlements .componentName (),
@@ -376,6 +376,10 @@ public void checkWriteProperty(Class<?> callerClass, String property) {
376376 );
377377 }
378378
379+ private static void notEntitled (String message ) {
380+ throw new NotEntitledException (message );
381+ }
382+
379383 public void checkManageThreadsEntitlement (Class <?> callerClass ) {
380384 checkEntitlementPresent (callerClass , ManageThreadsEntitlement .class );
381385 }
0 commit comments