You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "ygerzhedovich (via GitHub)" <gi...@apache.org> on 2025/01/02 12:04:34 UTC
[PR] IGNITE-24150 Ability to have different prefixes for exceptions [ignite-3]
ygerzhedovich opened a new pull request, #4991:
URL: https://github.com/apache/ignite-3/pull/4991
https://issues.apache.org/jira/browse/IGNITE-24150
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24150 Ability to have different prefixes for exceptions [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #4991:
URL: https://github.com/apache/ignite-3/pull/4991#discussion_r1916949445
##########
modules/api/src/main/java/org/apache/ignite/lang/ErrorGroups.java:
##########
@@ -17,16 +17,33 @@
package org.apache.ignite.lang;
+import static java.util.regex.Pattern.DOTALL;
+
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.apache.ignite.error.code.annotations.ErrorCodeGroup;
+import org.jetbrains.annotations.Nullable;
/**
* Defines error groups and its errors.
*/
@SuppressWarnings("PublicInnerClass")
public class ErrorGroups {
+ /** Additional prefix that is used in a human-readable format of ignite errors. */
+ public static final String IGNITE_ERR_PREFIX = "IGN";
Review Comment:
done
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24150 Ability to have different prefixes for exceptions [ignite-3]
Posted by "sk0x50 (via GitHub)" <gi...@apache.org>.
sk0x50 commented on code in PR #4991:
URL: https://github.com/apache/ignite-3/pull/4991#discussion_r1923153318
##########
modules/core/src/main/java/org/apache/ignite/internal/lang/ErrorGroupHelper.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.lang;
+
+import static org.apache.ignite.lang.ErrorGroup.extractErrorCode;
+
+import java.util.UUID;
+
+/**
+ * The class contains just single method which is fully copy of {@link ErrorGroup#errorMessage(String, UUID, String, int, String)} which is
+ * placed in public API and shouldn't be visible to outside. It required just to hide our internal things.
+ */
+class ErrorGroupHelper {
+
+ /**
+ * Creates a new error message with predefined prefix. Code of the method should be identical to {@code ErrorGroup.errorMessage}. We
+ * have code duplication just to remove from public api our dirty part.
+ *
+ * @param errorPrefix Prefix for the error.
+ * @param traceId Unique identifier of this exception.
+ * @param groupName Group name.
+ * @param code Full error code.
+ * @param message Original message.
+ * @return New error message with predefined prefix.
+ */
+ static String errorMessage(String errorPrefix, UUID traceId, String groupName, int code, String message) {
Review Comment:
I still think that this method is harmless and cannot be used in the wrong way. On the other hand, I don't want to argue about it either.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24150 Ability to have different prefixes for exceptions [ignite-3]
Posted by "sk0x50 (via GitHub)" <gi...@apache.org>.
sk0x50 commented on code in PR #4991:
URL: https://github.com/apache/ignite-3/pull/4991#discussion_r1923153318
##########
modules/core/src/main/java/org/apache/ignite/internal/lang/ErrorGroupHelper.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.lang;
+
+import static org.apache.ignite.lang.ErrorGroup.extractErrorCode;
+
+import java.util.UUID;
+
+/**
+ * The class contains just single method which is fully copy of {@link ErrorGroup#errorMessage(String, UUID, String, int, String)} which is
+ * placed in public API and shouldn't be visible to outside. It required just to hide our internal things.
+ */
+class ErrorGroupHelper {
+
+ /**
+ * Creates a new error message with predefined prefix. Code of the method should be identical to {@code ErrorGroup.errorMessage}. We
+ * have code duplication just to remove from public api our dirty part.
+ *
+ * @param errorPrefix Prefix for the error.
+ * @param traceId Unique identifier of this exception.
+ * @param groupName Group name.
+ * @param code Full error code.
+ * @param message Original message.
+ * @return New error message with predefined prefix.
+ */
+ static String errorMessage(String errorPrefix, UUID traceId, String groupName, int code, String message) {
Review Comment:
I still think that this method is harmless and cannot be used in the wrong way.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24150 Ability to have different prefixes for exceptions [ignite-3]
Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 commented on code in PR #4991:
URL: https://github.com/apache/ignite-3/pull/4991#discussion_r1905325066
##########
modules/api/src/main/java/org/apache/ignite/lang/ErrorGroup.java:
##########
@@ -125,62 +129,14 @@ public static String errorMessage(UUID traceId, int code, String message) {
* @param message Original message.
* @return New error message with predefined prefix.
*/
- public static String errorMessage(UUID traceId, String groupName, int code, String message) {
- return ERR_PREFIX + groupName + '-' + Short.toUnsignedInt(extractErrorCode(code)) + " TraceId:" + traceId
+ public static String errorMessage(String errorPrefix, UUID traceId, String groupName, int code, String message) {
Review Comment:
first, we need to update javadoc. Second, I would propose to do this method package private or even private. The reason is its contract: it accepts `errorPrefix`, `groupName`, and full error `code`, which must correspond to each other
##########
modules/api/src/main/java/org/apache/ignite/lang/ErrorGroups.java:
##########
@@ -73,13 +104,36 @@ public static synchronized ErrorGroup registerGroup(String groupName, short grou
}
}
- ErrorGroup newGroup = new ErrorGroup(grpName, groupCode);
+ if (REGISTERED_ERROR_PREFIXES.add(errorPrefix)) {
+ String errorPrefixes = String.join("|", REGISTERED_ERROR_PREFIXES);
+ String pattern = EXCEPTION_MESSAGE_STRING_PATTERN.replace(PLACEHOLDER, errorPrefixes);
+ EXCEPTION_MESSAGE_PATTERN = Pattern.compile(pattern, DOTALL);
Review Comment:
do we really need to recompile pattern every time? I would prefer to go with more simple pattern, and do post validation like `REGISTERED_ERROR_PREFIXES.contains(prefix)` if this really necessary
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24150 Ability to have different prefixes for exceptions [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #4991:
URL: https://github.com/apache/ignite-3/pull/4991#discussion_r1905749162
##########
modules/api/src/main/java/org/apache/ignite/lang/ErrorGroups.java:
##########
@@ -73,13 +104,36 @@ public static synchronized ErrorGroup registerGroup(String groupName, short grou
}
}
- ErrorGroup newGroup = new ErrorGroup(grpName, groupCode);
+ if (REGISTERED_ERROR_PREFIXES.add(errorPrefix)) {
+ String errorPrefixes = String.join("|", REGISTERED_ERROR_PREFIXES);
+ String pattern = EXCEPTION_MESSAGE_STRING_PATTERN.replace(PLACEHOLDER, errorPrefixes);
+ EXCEPTION_MESSAGE_PATTERN = Pattern.compile(pattern, DOTALL);
Review Comment:
What does mean `every time`? Just once per each a new error prefix. I don't see benefits for moving it from start node to the first use
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24150 Ability to have different prefixes for exceptions [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #4991:
URL: https://github.com/apache/ignite-3/pull/4991#discussion_r1905746083
##########
modules/api/src/main/java/org/apache/ignite/lang/ErrorGroup.java:
##########
@@ -125,62 +129,14 @@ public static String errorMessage(UUID traceId, int code, String message) {
* @param message Original message.
* @return New error message with predefined prefix.
*/
- public static String errorMessage(UUID traceId, String groupName, int code, String message) {
- return ERR_PREFIX + groupName + '-' + Short.toUnsignedInt(extractErrorCode(code)) + " TraceId:" + traceId
+ public static String errorMessage(String errorPrefix, UUID traceId, String groupName, int code, String message) {
Review Comment:
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24150 Ability to have different prefixes for exceptions [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #4991:
URL: https://github.com/apache/ignite-3/pull/4991#discussion_r1916961552
##########
modules/core/src/main/java/org/apache/ignite/internal/lang/ErrorGroupHelper.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.lang;
+
+import static org.apache.ignite.lang.ErrorGroup.extractErrorCode;
+
+import java.util.UUID;
+
+/**
+ * The class contains just single method which is fully copy of {@link ErrorGroup#errorMessage(String, UUID, String, int, String)} which is
+ * placed in public API and shouldn't be visible to outside. It required just to hide our internal things.
+ */
+class ErrorGroupHelper {
+
+ /**
+ * Creates a new error message with predefined prefix. Code of the method should be identical to {@code ErrorGroup.errorMessage}. We
+ * have code duplication just to remove from public api our dirty part.
+ *
+ * @param errorPrefix Prefix for the error.
+ * @param traceId Unique identifier of this exception.
+ * @param groupName Group name.
+ * @param code Full error code.
+ * @param message Original message.
+ * @return New error message with predefined prefix.
+ */
+ static String errorMessage(String errorPrefix, UUID traceId, String groupName, int code, String message) {
Review Comment:
https://github.com/apache/ignite-3/pull/4991#discussion_r1905325066
We have two chairs here -introduce in public API method which not required for user and can be used wrong or make a small duplication.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24150 Ability to have different prefixes for exceptions [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich merged PR #4991:
URL: https://github.com/apache/ignite-3/pull/4991
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24150 Ability to have different prefixes for exceptions [ignite-3]
Posted by "sk0x50 (via GitHub)" <gi...@apache.org>.
sk0x50 commented on code in PR #4991:
URL: https://github.com/apache/ignite-3/pull/4991#discussion_r1916425982
##########
modules/api/src/main/java/org/apache/ignite/lang/ErrorGroup.java:
##########
@@ -17,46 +17,49 @@
package org.apache.ignite.lang;
-import static java.util.regex.Pattern.DOTALL;
import static org.apache.ignite.lang.ErrorGroups.errorGroupByCode;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.jetbrains.annotations.Nullable;
/**
* This class represents a concept of error group. Error group defines a collection of errors that belong to a single semantic component.
* Each group can be identified by a name and an integer number that both must be unique across all error groups.
*/
public class ErrorGroup {
- /** Additional prefix that is used in a human-readable format of ignite errors. */
- public static final String ERR_PREFIX = "IGN-";
-
- /** Error message pattern. */
- private static final Pattern EXCEPTION_MESSAGE_PATTERN =
- Pattern.compile("(.*)(IGN)-([A-Z]+)-(\\d+)\\s(TraceId:)([a-f0-9]{8}(?:-[a-f0-9]{4}){4}[a-f0-9]{8})(\\s?)(.*)", DOTALL);
-
/** Group name. */
private final String groupName;
/** Group code. */
private final short groupCode;
+ /** Additional prefix that is used in a human-readable format of error messages. */
+ private final String errorPrefix;
Review Comment:
Hmm, I'm a little confused by the name. Perhaps, it would be nice to change to `groupNamePrefix`, or `vendorSpecificPrefix` etc. What do you think?
##########
modules/core/src/main/java/org/apache/ignite/internal/lang/ErrorGroupHelper.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.lang;
+
+import static org.apache.ignite.lang.ErrorGroup.extractErrorCode;
+
+import java.util.UUID;
+
+/**
+ * The class contains just single method which is fully copy of {@link ErrorGroup#errorMessage(String, UUID, String, int, String)} which is
+ * placed in public API and shouldn't be visible to outside. It required just to hide our internal things.
+ */
+class ErrorGroupHelper {
+
+ /**
+ * Creates a new error message with predefined prefix. Code of the method should be identical to {@code ErrorGroup.errorMessage}. We
+ * have code duplication just to remove from public api our dirty part.
+ *
+ * @param errorPrefix Prefix for the error.
+ * @param traceId Unique identifier of this exception.
+ * @param groupName Group name.
+ * @param code Full error code.
+ * @param message Original message.
+ * @return New error message with predefined prefix.
+ */
+ static String errorMessage(String errorPrefix, UUID traceId, String groupName, int code, String message) {
Review Comment:
Honestly, I don't like this idea. I mean creating a new class with duplicating code looks odd to me.
##########
modules/api/src/main/java/org/apache/ignite/lang/ErrorGroups.java:
##########
@@ -17,16 +17,33 @@
package org.apache.ignite.lang;
+import static java.util.regex.Pattern.DOTALL;
+
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.apache.ignite.error.code.annotations.ErrorCodeGroup;
+import org.jetbrains.annotations.Nullable;
/**
* Defines error groups and its errors.
*/
@SuppressWarnings("PublicInnerClass")
public class ErrorGroups {
+ /** Additional prefix that is used in a human-readable format of ignite errors. */
+ public static final String IGNITE_ERR_PREFIX = "IGN";
Review Comment:
Perhaps, the following code should be updated as well https://github.com/apache/ignite-3/blob/6b4a633dcce8360741da90f6dc42a73f574defca/modules/platforms/dotnet/Apache.Ignite/ErrorGroups.cs#L39
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24150 Ability to have different prefixes for exceptions [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #4991:
URL: https://github.com/apache/ignite-3/pull/4991#discussion_r1916964205
##########
modules/api/src/main/java/org/apache/ignite/lang/ErrorGroup.java:
##########
@@ -17,46 +17,49 @@
package org.apache.ignite.lang;
-import static java.util.regex.Pattern.DOTALL;
import static org.apache.ignite.lang.ErrorGroups.errorGroupByCode;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.jetbrains.annotations.Nullable;
/**
* This class represents a concept of error group. Error group defines a collection of errors that belong to a single semantic component.
* Each group can be identified by a name and an integer number that both must be unique across all error groups.
*/
public class ErrorGroup {
- /** Additional prefix that is used in a human-readable format of ignite errors. */
- public static final String ERR_PREFIX = "IGN-";
-
- /** Error message pattern. */
- private static final Pattern EXCEPTION_MESSAGE_PATTERN =
- Pattern.compile("(.*)(IGN)-([A-Z]+)-(\\d+)\\s(TraceId:)([a-f0-9]{8}(?:-[a-f0-9]{4}){4}[a-f0-9]{8})(\\s?)(.*)", DOTALL);
-
/** Group name. */
private final String groupName;
/** Group code. */
private final short groupCode;
+ /** Additional prefix that is used in a human-readable format of error messages. */
+ private final String errorPrefix;
Review Comment:
If we honestly it's not so important and all variants reflect nature of the field but from different perspective
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org