You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/05/06 09:16:24 UTC

[GitHub] [ignite] dgarus opened a new pull request #7772: IGNITE-12983 Logging exceptions inside IgniteSecurityProcessor#withContext(java.util.UUID)

dgarus opened a new pull request #7772:
URL: https://github.com/apache/ignite/pull/7772


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] nizhikov commented on a change in pull request #7772: IGNITE-12983 Logging exceptions inside IgniteSecurityProcessor#withContext(java.util.UUID)

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #7772:
URL: https://github.com/apache/ignite/pull/7772#discussion_r421494503



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/security/IgniteSecurityProcessor.java
##########
@@ -125,17 +133,30 @@ public IgniteSecurityProcessor(GridKernalContext ctx, GridSecurityProcessor secP
 
     /** {@inheritDoc} */
     @Override public OperationSecurityContext withContext(UUID subjId) {
-        ClusterNode node = Optional.ofNullable(ctx.discovery().node(subjId))
-            .orElseGet(() -> ctx.discovery().historicalNode(subjId));
+        RuntimeException error;
+
+        try {
+            ClusterNode node = Optional.ofNullable(ctx.discovery().node(subjId))
+                .orElseGet(() -> ctx.discovery().historicalNode(subjId));
+
+            SecurityContext res = node != null ? secCtxs.computeIfAbsent(subjId,
+                uuid -> nodeSecurityContext(marsh, U.resolveClassLoader(ctx.config()), node))
+                : secPrc.securityContext(subjId);
 
-        SecurityContext res = node != null ? secCtxs.computeIfAbsent(subjId,
-            uuid -> nodeSecurityContext(marsh, U.resolveClassLoader(ctx.config()), node))
-            : secPrc.securityContext(subjId);
+            if (res != null)
+                return withContext(res);
+
+            error = new IllegalStateException("Failed to find security context for subject with given ID : " + subjId);

Review comment:
       ```
       if (res != null)
           return withContext(res);
   }
   catch (Throwable e) {
       log.error(MSG, e);
       throw e;
   }
   
   String msg = "Failed to find security context for subject with given ID : " + subjId;
   
   log.error(msg);
   throw new IllegalStateException(msg);




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] dgarus commented on a change in pull request #7772: IGNITE-12983 Logging exceptions inside IgniteSecurityProcessor#withContext(java.util.UUID)

Posted by GitBox <gi...@apache.org>.
dgarus commented on a change in pull request #7772:
URL: https://github.com/apache/ignite/pull/7772#discussion_r421490509



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/security/IgniteSecurityProcessor.java
##########
@@ -125,17 +130,24 @@ public IgniteSecurityProcessor(GridKernalContext ctx, GridSecurityProcessor secP
 
     /** {@inheritDoc} */
     @Override public OperationSecurityContext withContext(UUID subjId) {
-        ClusterNode node = Optional.ofNullable(ctx.discovery().node(subjId))
-            .orElseGet(() -> ctx.discovery().historicalNode(subjId));
+        try {
+            ClusterNode node = Optional.ofNullable(ctx.discovery().node(subjId))
+                .orElseGet(() -> ctx.discovery().historicalNode(subjId));
+
+            SecurityContext res = node != null ? secCtxs.computeIfAbsent(subjId,
+                uuid -> nodeSecurityContext(marsh, U.resolveClassLoader(ctx.config()), node))
+                : secPrc.securityContext(subjId);
 
-        SecurityContext res = node != null ? secCtxs.computeIfAbsent(subjId,
-            uuid -> nodeSecurityContext(marsh, U.resolveClassLoader(ctx.config()), node))
-            : secPrc.securityContext(subjId);
+            if (res == null)
+                throw new IllegalStateException("Failed to find security context for subject with given ID : " + subjId);

Review comment:
       @nizhikov fixed




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] nizhikov commented on a change in pull request #7772: IGNITE-12983 Logging exceptions inside IgniteSecurityProcessor#withContext(java.util.UUID)

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #7772:
URL: https://github.com/apache/ignite/pull/7772#discussion_r421446405



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/security/IgniteSecurityProcessor.java
##########
@@ -125,17 +130,24 @@ public IgniteSecurityProcessor(GridKernalContext ctx, GridSecurityProcessor secP
 
     /** {@inheritDoc} */
     @Override public OperationSecurityContext withContext(UUID subjId) {
-        ClusterNode node = Optional.ofNullable(ctx.discovery().node(subjId))
-            .orElseGet(() -> ctx.discovery().historicalNode(subjId));
+        try {
+            ClusterNode node = Optional.ofNullable(ctx.discovery().node(subjId))
+                .orElseGet(() -> ctx.discovery().historicalNode(subjId));
+
+            SecurityContext res = node != null ? secCtxs.computeIfAbsent(subjId,
+                uuid -> nodeSecurityContext(marsh, U.resolveClassLoader(ctx.config()), node))
+                : secPrc.securityContext(subjId);
 
-        SecurityContext res = node != null ? secCtxs.computeIfAbsent(subjId,
-            uuid -> nodeSecurityContext(marsh, U.resolveClassLoader(ctx.config()), node))
-            : secPrc.securityContext(subjId);
+            if (res == null)
+                throw new IllegalStateException("Failed to find security context for subject with given ID : " + subjId);

Review comment:
       We can log it before throw.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] nizhikov commented on a change in pull request #7772: IGNITE-12983 Logging exceptions inside IgniteSecurityProcessor#withContext(java.util.UUID)

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #7772:
URL: https://github.com/apache/ignite/pull/7772#discussion_r421419886



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/security/IgniteSecurityProcessor.java
##########
@@ -125,17 +130,24 @@ public IgniteSecurityProcessor(GridKernalContext ctx, GridSecurityProcessor secP
 
     /** {@inheritDoc} */
     @Override public OperationSecurityContext withContext(UUID subjId) {
-        ClusterNode node = Optional.ofNullable(ctx.discovery().node(subjId))
-            .orElseGet(() -> ctx.discovery().historicalNode(subjId));
+        try {
+            ClusterNode node = Optional.ofNullable(ctx.discovery().node(subjId))
+                .orElseGet(() -> ctx.discovery().historicalNode(subjId));
+
+            SecurityContext res = node != null ? secCtxs.computeIfAbsent(subjId,
+                uuid -> nodeSecurityContext(marsh, U.resolveClassLoader(ctx.config()), node))
+                : secPrc.securityContext(subjId);
 
-        SecurityContext res = node != null ? secCtxs.computeIfAbsent(subjId,
-            uuid -> nodeSecurityContext(marsh, U.resolveClassLoader(ctx.config()), node))
-            : secPrc.securityContext(subjId);
+            if (res == null)
+                throw new IllegalStateException("Failed to find security context for subject with given ID : " + subjId);

Review comment:
       What's the point throw an Exception and catch it two lines later?
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] nizhikov commented on a change in pull request #7772: IGNITE-12983 Logging exceptions inside IgniteSecurityProcessor#withContext(java.util.UUID)

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #7772:
URL: https://github.com/apache/ignite/pull/7772#discussion_r421494503



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/security/IgniteSecurityProcessor.java
##########
@@ -125,17 +133,30 @@ public IgniteSecurityProcessor(GridKernalContext ctx, GridSecurityProcessor secP
 
     /** {@inheritDoc} */
     @Override public OperationSecurityContext withContext(UUID subjId) {
-        ClusterNode node = Optional.ofNullable(ctx.discovery().node(subjId))
-            .orElseGet(() -> ctx.discovery().historicalNode(subjId));
+        RuntimeException error;
+
+        try {
+            ClusterNode node = Optional.ofNullable(ctx.discovery().node(subjId))
+                .orElseGet(() -> ctx.discovery().historicalNode(subjId));
+
+            SecurityContext res = node != null ? secCtxs.computeIfAbsent(subjId,
+                uuid -> nodeSecurityContext(marsh, U.resolveClassLoader(ctx.config()), node))
+                : secPrc.securityContext(subjId);
 
-        SecurityContext res = node != null ? secCtxs.computeIfAbsent(subjId,
-            uuid -> nodeSecurityContext(marsh, U.resolveClassLoader(ctx.config()), node))
-            : secPrc.securityContext(subjId);
+            if (res != null)
+                return withContext(res);
+
+            error = new IllegalStateException("Failed to find security context for subject with given ID : " + subjId);

Review comment:
       ```
   if (res != null)
       return withContext(res);
   }
   catch (Throwable e) {
       log.error(MSG, e);
       throw e;
   }
   
   String msg = "Failed to find security context for subject with given ID : " + subjId;
   
   log.error(msg);
   throw new IllegalStateException(msg);




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] dgarus commented on a change in pull request #7772: IGNITE-12983 Logging exceptions inside IgniteSecurityProcessor#withContext(java.util.UUID)

Posted by GitBox <gi...@apache.org>.
dgarus commented on a change in pull request #7772:
URL: https://github.com/apache/ignite/pull/7772#discussion_r421444292



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/security/IgniteSecurityProcessor.java
##########
@@ -125,17 +130,24 @@ public IgniteSecurityProcessor(GridKernalContext ctx, GridSecurityProcessor secP
 
     /** {@inheritDoc} */
     @Override public OperationSecurityContext withContext(UUID subjId) {
-        ClusterNode node = Optional.ofNullable(ctx.discovery().node(subjId))
-            .orElseGet(() -> ctx.discovery().historicalNode(subjId));
+        try {
+            ClusterNode node = Optional.ofNullable(ctx.discovery().node(subjId))
+                .orElseGet(() -> ctx.discovery().historicalNode(subjId));
+
+            SecurityContext res = node != null ? secCtxs.computeIfAbsent(subjId,
+                uuid -> nodeSecurityContext(marsh, U.resolveClassLoader(ctx.config()), node))
+                : secPrc.securityContext(subjId);
 
-        SecurityContext res = node != null ? secCtxs.computeIfAbsent(subjId,
-            uuid -> nodeSecurityContext(marsh, U.resolveClassLoader(ctx.config()), node))
-            : secPrc.securityContext(subjId);
+            if (res == null)
+                throw new IllegalStateException("Failed to find security context for subject with given ID : " + subjId);

Review comment:
       @nizhikov 
   After logging inside the catch block, this exception will be thrown outside where it can be handled.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org