sergey-chugunov-1985 commented on code in PR #13414:
URL: https://github.com/apache/ignite/pull/13414#discussion_r3681116333
##########
modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java:
##########
@@ -109,6 +110,9 @@ public class MessageSerializerGenerator extends
MessageCompanionGenerator {
/** */
private final List<String> read = new ArrayList<>();
+ /** Class fields, which should come before ordinary class fields. */
Review Comment:
```suggestion
/** Static class fields, which should come before ordinary class fields.
*/
```
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/security/SecurityUtils.java:
##########
@@ -372,4 +373,59 @@ private static void authorizeAll(IgniteSecurity security,
Map<String, Collection
permissions.forEach((name, permsPerName) -> permsPerName.forEach(perm
-> security.authorize(name, perm)));
}
+
+ /**
+ * Perfroms deep equals of permission sets.
+ *
+ * @param lhs First permissions set for equality check.
+ * @param rhs Second permissions set for equality check.
+ * @return Whether specified permission sets are equal.
+ */
+ public static boolean deepEquals(SecurityPermissionSet lhs,
SecurityPermissionSet rhs) {
+ if (lhs == rhs)
+ return true;
+
+ return lhs != null
+ && rhs != null
+ && lhs.defaultAllowAll() == rhs.defaultAllowAll()
+ && (F.isEmpty(rhs.systemPermissions()) &&
F.isEmpty(rhs.systemPermissions())
+ || F.eqNotOrdered(rhs.systemPermissions(),
lhs.systemPermissions()))
+ && eqNotOrdered(rhs.taskPermissions(), lhs.taskPermissions())
+ && eqNotOrdered(rhs.servicePermissions(), lhs.servicePermissions())
+ && eqNotOrdered(rhs.cachePermissions(), lhs.cachePermissions());
+ }
+
+ /**
+ * @param m1 First map to check.
+ * @param m2 Second map to check
+ * @return {@code True} is maps are equal, {@code False} otherwise.
+ */
+ public static boolean eqNotOrdered(
+ @Nullable Map<String, Collection<SecurityPermission>> m1,
+ @Nullable Map<String, Collection<SecurityPermission>> m2) {
+ if (m1 == m2)
+ return true;
+
+ if (m1 == null || m2 == null)
+ return false;
+
+ if (m1.size() != m2.size())
+ return false;
+
+ for (Map.Entry<String, Collection<SecurityPermission>> e :
m1.entrySet()) {
+ Collection<SecurityPermission> v1 = e.getValue();
+ Collection<SecurityPermission> v2 = m2.get(e.getKey());
+
+ if (v1 == v2)
+ continue;
+
+ if (v1 == null || v2 == null)
Review Comment:
I suspect we don't need to do null checks here separately because
F.eqNotOrdered already contains null checks - could you take a look and decide
if we indeed can drop this?
##########
modules/codegen/src/main/java/org/apache/ignite/internal/MessageProcessor.java:
##########
@@ -120,6 +123,9 @@ public class MessageProcessor extends AbstractProcessor {
/** */
private final Map<String, IgniteBiTuple<String, String>> enumMappersInUse
= new HashMap<>();
+ /** */
+ private final Map<Element, String> enumsPerField = new HashMap<>();
Review Comment:
I think it should be possible to turn this field into a parameter of
validateEnumType method and initialize it inside the method when necessage.
By doing so we would eliminate a MessageProcessor's level field which is
relevant only for validation process of an isolated message field and get rid
of a bit confusing clearing `enumsPerField` in `validateEnumbFieldMapping`
method.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]