This is an automated email from the ASF dual-hosted git repository.
gosullivan pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 10a9124 GEODE-4403: Remove ProtobufErrorCode (#1432)
10a9124 is described below
commit 10a91241ff3fca5ba5b3edf818a0ea433879bedd
Author: Galen O'Sullivan <[email protected]>
AuthorDate: Wed Feb 14 08:25:09 2018 -0800
GEODE-4403: Remove ProtobufErrorCode (#1432)
as it's a duplicate of BasicTypes.ErrorCode
---
.../protocol/protobuf/v1/ProtobufErrorCode.java | 32 ----------------
.../protocol/protobuf/v1/ProtobufOpsProcessor.java | 2 +-
.../operations/GetAllRequestOperationHandler.java | 19 ++++------
.../GetRegionRequestOperationHandler.java | 6 +--
.../v1/operations/GetRequestOperationHandler.java | 11 ++----
.../v1/operations/GetServerOperationHandler.java | 3 +-
.../operations/PutAllRequestOperationHandler.java | 18 ++++-----
.../v1/operations/PutRequestOperationHandler.java | 15 ++++----
.../operations/RemoveRequestOperationHandler.java | 12 +++---
...cySecurityProtobufConnectionStateProcessor.java | 6 +--
...NoSecurityProtobufConnectionStateProcessor.java | 4 +-
...obufConnectionAuthenticatingStateProcessor.java | 4 +-
...rotobufConnectionAuthorizingStateProcessor.java | 6 +--
.../ProtobufConnectionHandshakeStateProcessor.java | 4 +-
.../v1/state/ProtobufConnectionStateProcessor.java | 4 +-
...rotobufConnectionTerminatingStateProcessor.java | 4 +-
.../state/exception/ConnectionStateException.java | 8 ++--
.../exception/OperationNotAuthorizedException.java | 5 ++-
.../v1/utilities/ProtobufResponseUtilities.java | 6 +--
.../protobuf/v1/utilities/ProtobufUtilities.java | 11 ------
.../protocol/protobuf/v1/ErrorCodesJUnitTest.java | 44 ----------------------
21 files changed, 60 insertions(+), 164 deletions(-)
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufErrorCode.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufErrorCode.java
deleted file mode 100644
index 100f685..0000000
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufErrorCode.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.geode.internal.protocol.protobuf.v1;
-
-public enum ProtobufErrorCode {
- AUTHENTICATION_REQUIRED(10),
- AUTHENTICATION_FAILED(11),
- ALREADY_AUTHENTICATED(12),
- AUTHENTICATION_NOT_SUPPORTED(13),
- AUTHORIZATION_FAILED(20),
- INVALID_REQUEST(50),
- SERVER_ERROR(100),
- NO_AVAILABLE_SERVER(101);
-
- ProtobufErrorCode(int value) {
- codeValue = value;
- }
-
- public int codeValue;
-}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufOpsProcessor.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufOpsProcessor.java
index e9d3beb..794f22b 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufOpsProcessor.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufOpsProcessor.java
@@ -78,7 +78,7 @@ public class ProtobufOpsProcessor {
} catch (InvalidExecutionContextException exception) {
logger.error("Invalid execution context found for operation {}",
requestType);
return Failure.of(ProtobufResponseUtilities.makeErrorResponse(
- ProtobufErrorCode.INVALID_REQUEST, "Invalid execution context found
for operation."));
+ BasicTypes.ErrorCode.INVALID_REQUEST, "Invalid execution context
found for operation."));
}
}
}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetAllRequestOperationHandler.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetAllRequestOperationHandler.java
index 7700d4f..20f1388 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetAllRequestOperationHandler.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetAllRequestOperationHandler.java
@@ -14,10 +14,6 @@
*/
package org.apache.geode.internal.protocol.protobuf.v1.operations;
-
-import static
org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode.INVALID_REQUEST;
-import static
org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode.SERVER_ERROR;
-
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -34,7 +30,6 @@ import
org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
import org.apache.geode.internal.protocol.protobuf.v1.ClientProtocol;
import org.apache.geode.internal.protocol.protobuf.v1.Failure;
import org.apache.geode.internal.protocol.protobuf.v1.MessageExecutionContext;
-import org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode;
import
org.apache.geode.internal.protocol.protobuf.v1.ProtobufSerializationService;
import org.apache.geode.internal.protocol.protobuf.v1.RegionAPI;
import org.apache.geode.internal.protocol.protobuf.v1.Result;
@@ -56,8 +51,8 @@ public class GetAllRequestOperationHandler
Region region = messageExecutionContext.getCache().getRegion(regionName);
if (region == null) {
logger.error("Received GetAll request for non-existing region {}",
regionName);
- return Failure
- .of(ProtobufResponseUtilities.makeErrorResponse(SERVER_ERROR,
"Region not found"));
+ return Failure.of(ProtobufResponseUtilities
+ .makeErrorResponse(BasicTypes.ErrorCode.SERVER_ERROR, "Region not
found"));
}
long startTime = messageExecutionContext.getStatistics().startOperation();
@@ -93,17 +88,17 @@ public class GetAllRequestOperationHandler
return ProtobufUtilities.createEntry(serializationService, decodedKey,
value);
} catch (EncodingException ex) {
logger.error("Encoding not supported: {}", ex);
- return createKeyedError(key, "Encoding not supported.", INVALID_REQUEST);
+ return createKeyedError(key, "Encoding not supported.",
BasicTypes.ErrorCode.INVALID_REQUEST);
} catch (Exception ex) {
logger.error("Failure in protobuf getAll operation for key: " + key, ex);
- return createKeyedError(key, ex.toString(), SERVER_ERROR);
+ return createKeyedError(key, ex.toString(),
BasicTypes.ErrorCode.SERVER_ERROR);
}
}
private Object createKeyedError(BasicTypes.EncodedValue key, String
errorMessage,
- ProtobufErrorCode errorCode) {
- return
BasicTypes.KeyedError.newBuilder().setKey(key).setError(BasicTypes.Error.newBuilder()
-
.setErrorCode(ProtobufUtilities.getProtobufErrorCode(errorCode)).setMessage(errorMessage))
+ BasicTypes.ErrorCode errorCode) {
+ return BasicTypes.KeyedError.newBuilder().setKey(key)
+
.setError(BasicTypes.Error.newBuilder().setErrorCode(errorCode).setMessage(errorMessage))
.build();
}
}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetRegionRequestOperationHandler.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetRegionRequestOperationHandler.java
index c57e2e8..4027614 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetRegionRequestOperationHandler.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetRegionRequestOperationHandler.java
@@ -14,8 +14,6 @@
*/
package org.apache.geode.internal.protocol.protobuf.v1.operations;
-import static
org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode.SERVER_ERROR;
-
import org.apache.logging.log4j.Logger;
import org.apache.geode.annotations.Experimental;
@@ -48,8 +46,8 @@ public class GetRegionRequestOperationHandler
Region region = messageExecutionContext.getCache().getRegion(regionName);
if (region == null) {
logger.error("Received GetRegion request for non-existing region {}",
regionName);
- return
Failure.of(ProtobufResponseUtilities.makeErrorResponse(SERVER_ERROR,
- "No region exists for name: " + regionName));
+ return Failure.of(ProtobufResponseUtilities.makeErrorResponse(
+ BasicTypes.ErrorCode.SERVER_ERROR, "No region exists for name: " +
regionName));
}
BasicTypes.Region protoRegion =
ProtobufUtilities.createRegionMessageFromRegion(region);
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetRequestOperationHandler.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetRequestOperationHandler.java
index 3f98819..5c2539e 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetRequestOperationHandler.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetRequestOperationHandler.java
@@ -14,9 +14,6 @@
*/
package org.apache.geode.internal.protocol.protobuf.v1.operations;
-import static
org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode.INVALID_REQUEST;
-import static
org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode.SERVER_ERROR;
-
import org.apache.logging.log4j.Logger;
import org.apache.geode.annotations.Experimental;
@@ -49,8 +46,8 @@ public class GetRequestOperationHandler
Region region = messageExecutionContext.getCache().getRegion(regionName);
if (region == null) {
logger.error("Received Get request for non-existing region {}",
regionName);
- return Failure
- .of(ProtobufResponseUtilities.makeErrorResponse(SERVER_ERROR,
"Region not found"));
+ return Failure.of(ProtobufResponseUtilities
+ .makeErrorResponse(BasicTypes.ErrorCode.SERVER_ERROR, "Region not
found"));
}
long startOperationTime =
messageExecutionContext.getStatistics().startOperation();
@@ -68,8 +65,8 @@ public class GetRequestOperationHandler
return
Success.of(RegionAPI.GetResponse.newBuilder().setResult(encodedValue).build());
} catch (EncodingException ex) {
logger.error("Received Get request with unsupported encoding: {}", ex);
- return Failure.of(
- ProtobufResponseUtilities.makeErrorResponse(INVALID_REQUEST,
"Encoding not supported."));
+ return Failure.of(ProtobufResponseUtilities
+ .makeErrorResponse(BasicTypes.ErrorCode.INVALID_REQUEST, "Encoding
not supported."));
} finally {
((InternalCache)
messageExecutionContext.getCache()).setReadSerializedForCurrentThread(false);
messageExecutionContext.getStatistics().endOperation(startOperationTime);
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetServerOperationHandler.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetServerOperationHandler.java
index 0db85b5..865d540 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetServerOperationHandler.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetServerOperationHandler.java
@@ -14,7 +14,8 @@
*/
package org.apache.geode.internal.protocol.protobuf.v1.operations;
-import static
org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode.NO_AVAILABLE_SERVER;
+
+import static
org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.ErrorCode.NO_AVAILABLE_SERVER;
import java.util.HashSet;
import java.util.List;
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/PutAllRequestOperationHandler.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/PutAllRequestOperationHandler.java
index 7446a90..5749eb8 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/PutAllRequestOperationHandler.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/PutAllRequestOperationHandler.java
@@ -14,9 +14,6 @@
*/
package org.apache.geode.internal.protocol.protobuf.v1.operations;
-import static
org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode.INVALID_REQUEST;
-import static
org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode.SERVER_ERROR;
-
import java.util.Objects;
import java.util.stream.Collectors;
@@ -31,7 +28,6 @@ import
org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
import org.apache.geode.internal.protocol.protobuf.v1.ClientProtocol;
import org.apache.geode.internal.protocol.protobuf.v1.Failure;
import org.apache.geode.internal.protocol.protobuf.v1.MessageExecutionContext;
-import org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode;
import
org.apache.geode.internal.protocol.protobuf.v1.ProtobufSerializationService;
import org.apache.geode.internal.protocol.protobuf.v1.RegionAPI;
import org.apache.geode.internal.protocol.protobuf.v1.Result;
@@ -55,8 +51,8 @@ public class PutAllRequestOperationHandler
if (region == null) {
logger.error("Received PutAll request for non-existing region {}",
regionName);
- return
Failure.of(ProtobufResponseUtilities.makeErrorResponse(SERVER_ERROR,
- "Region passed does not exist: " + regionName));
+ return Failure.of(ProtobufResponseUtilities.makeErrorResponse(
+ BasicTypes.ErrorCode.SERVER_ERROR, "Region passed does not exist: "
+ regionName));
}
long startTime = messageExecutionContext.getStatistics().startOperation();
@@ -76,20 +72,20 @@ public class PutAllRequestOperationHandler
region.put(decodedKey, decodedValue);
} catch (EncodingException ex) {
- return buildAndLogKeyedError(entry, INVALID_REQUEST, "Encoding not
supported", ex);
+ return buildAndLogKeyedError(entry, BasicTypes.ErrorCode.INVALID_REQUEST,
+ "Encoding not supported", ex);
} catch (ClassCastException ex) {
- return buildAndLogKeyedError(entry, SERVER_ERROR, ex.toString(), ex);
+ return buildAndLogKeyedError(entry, BasicTypes.ErrorCode.SERVER_ERROR,
ex.toString(), ex);
}
return null;
}
private BasicTypes.KeyedError buildAndLogKeyedError(BasicTypes.Entry entry,
- ProtobufErrorCode errorCode, String message, Exception ex) {
+ BasicTypes.ErrorCode errorCode, String message, Exception ex) {
logger.error(message, ex);
return BasicTypes.KeyedError.newBuilder().setKey(entry.getKey())
- .setError(BasicTypes.Error.newBuilder()
-
.setErrorCode(ProtobufUtilities.getProtobufErrorCode(errorCode)).setMessage(message))
+
.setError(BasicTypes.Error.newBuilder().setErrorCode(errorCode).setMessage(message))
.build();
}
}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/PutRequestOperationHandler.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/PutRequestOperationHandler.java
index 84da6de..5999c44 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/PutRequestOperationHandler.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/PutRequestOperationHandler.java
@@ -14,9 +14,6 @@
*/
package org.apache.geode.internal.protocol.protobuf.v1.operations;
-import static
org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode.INVALID_REQUEST;
-import static
org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode.SERVER_ERROR;
-
import org.apache.logging.log4j.Logger;
import org.apache.geode.annotations.Experimental;
@@ -48,8 +45,9 @@ public class PutRequestOperationHandler
Region region = messageExecutionContext.getCache().getRegion(regionName);
if (region == null) {
logger.warn("Received Put request for non-existing region: {}",
regionName);
- return
Failure.of(ProtobufResponseUtilities.makeErrorResponse(SERVER_ERROR,
- "Region passed by client did not exist: " + regionName));
+ return Failure
+
.of(ProtobufResponseUtilities.makeErrorResponse(BasicTypes.ErrorCode.SERVER_ERROR,
+ "Region passed by client did not exist: " + regionName));
}
long startTime = messageExecutionContext.getStatistics().startOperation();
@@ -63,12 +61,13 @@ public class PutRequestOperationHandler
return Success.of(RegionAPI.PutResponse.newBuilder().build());
} catch (ClassCastException ex) {
logger.error("Received Put request with invalid key type: {}", ex);
- return
Failure.of(ProtobufResponseUtilities.makeErrorResponse(SERVER_ERROR,
ex.toString()));
+ return Failure.of(ProtobufResponseUtilities
+ .makeErrorResponse(BasicTypes.ErrorCode.SERVER_ERROR,
ex.toString()));
}
} catch (EncodingException ex) {
logger.error("Got error when decoding Put request: {}", ex);
- return Failure
- .of(ProtobufResponseUtilities.makeErrorResponse(INVALID_REQUEST,
ex.toString()));
+ return Failure.of(ProtobufResponseUtilities
+ .makeErrorResponse(BasicTypes.ErrorCode.INVALID_REQUEST,
ex.toString()));
} finally {
messageExecutionContext.getStatistics().endOperation(startTime);
}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/RemoveRequestOperationHandler.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/RemoveRequestOperationHandler.java
index 34d2c69..1571a6c 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/RemoveRequestOperationHandler.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/RemoveRequestOperationHandler.java
@@ -14,9 +14,6 @@
*/
package org.apache.geode.internal.protocol.protobuf.v1.operations;
-import static
org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode.INVALID_REQUEST;
-import static
org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode.SERVER_ERROR;
-
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -24,6 +21,7 @@ import org.apache.geode.annotations.Experimental;
import org.apache.geode.cache.Region;
import org.apache.geode.internal.exception.InvalidExecutionContextException;
import org.apache.geode.internal.protocol.operations.ProtobufOperationHandler;
+import org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
import org.apache.geode.internal.protocol.protobuf.v1.ClientProtocol;
import org.apache.geode.internal.protocol.protobuf.v1.Failure;
import org.apache.geode.internal.protocol.protobuf.v1.MessageExecutionContext;
@@ -48,8 +46,8 @@ public class RemoveRequestOperationHandler
Region region = messageExecutionContext.getCache().getRegion(regionName);
if (region == null) {
logger.error("Received Remove request for non-existing region {}",
regionName);
- return Failure
- .of(ProtobufResponseUtilities.makeErrorResponse(SERVER_ERROR,
"Region not found"));
+ return Failure.of(ProtobufResponseUtilities
+ .makeErrorResponse(BasicTypes.ErrorCode.SERVER_ERROR, "Region not
found"));
}
long startTime = messageExecutionContext.getStatistics().startOperation();
@@ -61,8 +59,8 @@ public class RemoveRequestOperationHandler
} catch (EncodingException ex) {
// can be thrown by encoding or decoding.
logger.error("Received Remove request with unsupported encoding: {}",
ex);
- return
Failure.of(ProtobufResponseUtilities.makeErrorResponse(INVALID_REQUEST,
- "Encoding not supported: " + ex.getMessage()));
+ return Failure.of(ProtobufResponseUtilities.makeErrorResponse(
+ BasicTypes.ErrorCode.INVALID_REQUEST, "Encoding not supported: " +
ex.getMessage()));
} finally {
messageExecutionContext.getStatistics().endOperation(startTime);
}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/LegacySecurityProtobufConnectionStateProcessor.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/LegacySecurityProtobufConnectionStateProcessor.java
index 4cc1735..e996dfd 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/LegacySecurityProtobufConnectionStateProcessor.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/LegacySecurityProtobufConnectionStateProcessor.java
@@ -14,8 +14,8 @@
*/
package org.apache.geode.internal.protocol.protobuf.v1.state;
+import org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
import org.apache.geode.internal.protocol.protobuf.v1.MessageExecutionContext;
-import org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode;
import org.apache.geode.internal.protocol.protobuf.v1.ProtobufOperationContext;
import
org.apache.geode.internal.protocol.protobuf.v1.state.exception.ConnectionStateException;
@@ -24,14 +24,14 @@ public class LegacySecurityProtobufConnectionStateProcessor
@Override
public void validateOperation(MessageExecutionContext messageContext,
ProtobufOperationContext operationContext) throws
ConnectionStateException {
- throw new ConnectionStateException(ProtobufErrorCode.AUTHENTICATION_FAILED,
+ throw new
ConnectionStateException(BasicTypes.ErrorCode.AUTHENTICATION_FAILED,
"Attempting to authenticate incoming protobuf message using legacy
security implementation. This is not supported. Failing authentication.");
}
@Override
public ProtobufConnectionAuthenticatingStateProcessor allowAuthentication()
throws ConnectionStateException {
- throw new ConnectionStateException(ProtobufErrorCode.AUTHENTICATION_FAILED,
+ throw new
ConnectionStateException(BasicTypes.ErrorCode.AUTHENTICATION_FAILED,
"Attempting to authenticate incoming protobuf message using legacy
security implementation. This is not supported. Failing authentication.");
}
}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/NoSecurityProtobufConnectionStateProcessor.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/NoSecurityProtobufConnectionStateProcessor.java
index cb026da..d373f11 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/NoSecurityProtobufConnectionStateProcessor.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/NoSecurityProtobufConnectionStateProcessor.java
@@ -14,8 +14,8 @@
*/
package org.apache.geode.internal.protocol.protobuf.v1.state;
+import org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
import org.apache.geode.internal.protocol.protobuf.v1.MessageExecutionContext;
-import org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode;
import org.apache.geode.internal.protocol.protobuf.v1.ProtobufOperationContext;
import
org.apache.geode.internal.protocol.protobuf.v1.state.exception.ConnectionStateException;
@@ -27,7 +27,7 @@ public class NoSecurityProtobufConnectionStateProcessor
public ProtobufConnectionAuthenticatingStateProcessor allowAuthentication()
throws ConnectionStateException {
- throw new
ConnectionStateException(ProtobufErrorCode.AUTHENTICATION_NOT_SUPPORTED,
+ throw new
ConnectionStateException(BasicTypes.ErrorCode.AUTHENTICATION_NOT_SUPPORTED,
"This machine is not set to require user authentication.");
}
}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionAuthenticatingStateProcessor.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionAuthenticatingStateProcessor.java
index a30885f..4e030ee 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionAuthenticatingStateProcessor.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionAuthenticatingStateProcessor.java
@@ -18,8 +18,8 @@ import java.util.Properties;
import org.apache.shiro.subject.Subject;
+import org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
import org.apache.geode.internal.protocol.protobuf.v1.MessageExecutionContext;
-import org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode;
import org.apache.geode.internal.protocol.protobuf.v1.ProtobufOperationContext;
import
org.apache.geode.internal.protocol.protobuf.v1.operations.security.AuthenticationRequestOperationHandler;
import
org.apache.geode.internal.protocol.protobuf.v1.state.exception.ConnectionStateException;
@@ -39,7 +39,7 @@ public class ProtobufConnectionAuthenticatingStateProcessor
ProtobufOperationContext operationContext) throws
ConnectionStateException {
if (!(operationContext
.getOperationHandler() instanceof
AuthenticationRequestOperationHandler)) {
- throw new
ConnectionStateException(ProtobufErrorCode.AUTHENTICATION_FAILED,
+ throw new
ConnectionStateException(BasicTypes.ErrorCode.AUTHENTICATION_FAILED,
"User has not yet authenticated");
}
}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionAuthorizingStateProcessor.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionAuthorizingStateProcessor.java
index c2b8ad9..f3590d5 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionAuthorizingStateProcessor.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionAuthorizingStateProcessor.java
@@ -17,8 +17,8 @@ package org.apache.geode.internal.protocol.protobuf.v1.state;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.util.ThreadState;
+import org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
import org.apache.geode.internal.protocol.protobuf.v1.MessageExecutionContext;
-import org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode;
import org.apache.geode.internal.protocol.protobuf.v1.ProtobufOperationContext;
import
org.apache.geode.internal.protocol.protobuf.v1.state.exception.ConnectionStateException;
import
org.apache.geode.internal.protocol.protobuf.v1.state.exception.OperationNotAuthorizedException;
@@ -44,7 +44,7 @@ public class ProtobufConnectionAuthorizingStateProcessor
securityService.authorize(operationContext.getAccessPermissionRequired());
} catch (NotAuthorizedException e) {
messageContext.getStatistics().incAuthorizationViolations();
- throw new
OperationNotAuthorizedException(ProtobufErrorCode.AUTHORIZATION_FAILED,
+ throw new
OperationNotAuthorizedException(BasicTypes.ErrorCode.AUTHORIZATION_FAILED,
"The user is not authorized to complete this operation");
} finally {
threadState.restore();
@@ -54,7 +54,7 @@ public class ProtobufConnectionAuthorizingStateProcessor
@Override
public ProtobufConnectionAuthenticatingStateProcessor allowAuthentication()
throws ConnectionStateException {
- throw new ConnectionStateException(ProtobufErrorCode.ALREADY_AUTHENTICATED,
+ throw new
ConnectionStateException(BasicTypes.ErrorCode.ALREADY_AUTHENTICATED,
"The user has already been authenticated for this connection.
Re-authentication is not supported at this time.");
}
}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionHandshakeStateProcessor.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionHandshakeStateProcessor.java
index 0ab334c..b28d62d 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionHandshakeStateProcessor.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionHandshakeStateProcessor.java
@@ -20,8 +20,8 @@ import java.io.OutputStream;
import java.io.PushbackInputStream;
import org.apache.geode.internal.cache.tier.CommunicationMode;
+import org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
import org.apache.geode.internal.protocol.protobuf.v1.MessageExecutionContext;
-import org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode;
import org.apache.geode.internal.protocol.protobuf.v1.ProtobufOperationContext;
import
org.apache.geode.internal.protocol.protobuf.v1.operations.ProtocolVersionHandler;
import
org.apache.geode.internal.protocol.protobuf.v1.state.exception.ConnectionStateException;
@@ -37,7 +37,7 @@ public class ProtobufConnectionHandshakeStateProcessor
implements ProtobufConnec
@Override
public void validateOperation(MessageExecutionContext messageContext,
ProtobufOperationContext operationContext) throws
ConnectionStateException {
- throw new ConnectionStateException(ProtobufErrorCode.INVALID_REQUEST,
+ throw new ConnectionStateException(BasicTypes.ErrorCode.INVALID_REQUEST,
"Connection processing should never be asked to validate an
operation");
}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionStateProcessor.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionStateProcessor.java
index 2ef75d9..1898f59 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionStateProcessor.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionStateProcessor.java
@@ -18,8 +18,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
import org.apache.geode.internal.protocol.protobuf.v1.MessageExecutionContext;
-import org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode;
import org.apache.geode.internal.protocol.protobuf.v1.ProtobufOperationContext;
import
org.apache.geode.internal.protocol.protobuf.v1.state.exception.ConnectionStateException;
@@ -47,7 +47,7 @@ public interface ProtobufConnectionStateProcessor {
*/
default ProtobufConnectionAuthenticatingStateProcessor allowAuthentication()
throws ConnectionStateException {
- throw new
ConnectionStateException(ProtobufErrorCode.AUTHENTICATION_REQUIRED,
+ throw new
ConnectionStateException(BasicTypes.ErrorCode.AUTHENTICATION_REQUIRED,
"Authentication is required before processing further requests");
}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionTerminatingStateProcessor.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionTerminatingStateProcessor.java
index 8d069bf..e884e2c 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionTerminatingStateProcessor.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionTerminatingStateProcessor.java
@@ -14,8 +14,8 @@
*/
package org.apache.geode.internal.protocol.protobuf.v1.state;
+import org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
import org.apache.geode.internal.protocol.protobuf.v1.MessageExecutionContext;
-import org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode;
import org.apache.geode.internal.protocol.protobuf.v1.ProtobufOperationContext;
import
org.apache.geode.internal.protocol.protobuf.v1.state.exception.ConnectionStateException;
@@ -24,7 +24,7 @@ public class ProtobufConnectionTerminatingStateProcessor
@Override
public void validateOperation(MessageExecutionContext messageContext,
ProtobufOperationContext operationContext) throws
ConnectionStateException {
- throw new ConnectionStateException(ProtobufErrorCode.SERVER_ERROR,
+ throw new ConnectionStateException(BasicTypes.ErrorCode.SERVER_ERROR,
"This connection has been marked as terminating.");
}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/exception/ConnectionStateException.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/exception/ConnectionStateException.java
index be9fa33..8e543b6 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/exception/ConnectionStateException.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/exception/ConnectionStateException.java
@@ -15,17 +15,17 @@
package org.apache.geode.internal.protocol.protobuf.v1.state.exception;
-import org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode;
+import org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
public class ConnectionStateException extends Exception {
- private final ProtobufErrorCode errorCode;
+ private final BasicTypes.ErrorCode errorCode;
- public ConnectionStateException(ProtobufErrorCode errorCode, String
errorMessage) {
+ public ConnectionStateException(BasicTypes.ErrorCode errorCode, String
errorMessage) {
super(errorMessage);
this.errorCode = errorCode;
}
- public ProtobufErrorCode getErrorCode() {
+ public BasicTypes.ErrorCode getErrorCode() {
return errorCode;
}
}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/exception/OperationNotAuthorizedException.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/exception/OperationNotAuthorizedException.java
index ccd9135..f65f88e 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/exception/OperationNotAuthorizedException.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/exception/OperationNotAuthorizedException.java
@@ -14,10 +14,11 @@
*/
package org.apache.geode.internal.protocol.protobuf.v1.state.exception;
-import org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode;
+
+import org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
public class OperationNotAuthorizedException extends ConnectionStateException {
- public OperationNotAuthorizedException(ProtobufErrorCode errorCode, String
errorMessage) {
+ public OperationNotAuthorizedException(BasicTypes.ErrorCode errorCode,
String errorMessage) {
super(errorCode, errorMessage);
}
}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/utilities/ProtobufResponseUtilities.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/utilities/ProtobufResponseUtilities.java
index 84c8600..c8814af 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/utilities/ProtobufResponseUtilities.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/utilities/ProtobufResponseUtilities.java
@@ -20,7 +20,6 @@ import org.apache.geode.annotations.Experimental;
import org.apache.geode.cache.Region;
import org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
import org.apache.geode.internal.protocol.protobuf.v1.ClientProtocol;
-import org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode;
import org.apache.geode.internal.protocol.protobuf.v1.RegionAPI;
import
org.apache.geode.internal.protocol.protobuf.v1.state.exception.ConnectionStateException;
@@ -50,11 +49,10 @@ public abstract class ProtobufResponseUtilities {
return builder.build();
}
- public static ClientProtocol.ErrorResponse
makeErrorResponse(ProtobufErrorCode errorCode,
+ public static ClientProtocol.ErrorResponse
makeErrorResponse(BasicTypes.ErrorCode errorCode,
String message) {
return ClientProtocol.ErrorResponse.newBuilder()
- .setError(BasicTypes.Error.newBuilder()
-
.setErrorCode(ProtobufUtilities.getProtobufErrorCode(errorCode)).setMessage(message))
+
.setError(BasicTypes.Error.newBuilder().setErrorCode(errorCode).setMessage(message))
.build();
}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/utilities/ProtobufUtilities.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/utilities/ProtobufUtilities.java
index 12d7305..c42cc16 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/utilities/ProtobufUtilities.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/utilities/ProtobufUtilities.java
@@ -19,7 +19,6 @@ import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionAttributes;
import org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
import org.apache.geode.internal.protocol.protobuf.v1.ClientProtocol;
-import org.apache.geode.internal.protocol.protobuf.v1.ProtobufErrorCode;
import
org.apache.geode.internal.protocol.protobuf.v1.ProtobufSerializationService;
import org.apache.geode.internal.protocol.protobuf.v1.RegionAPI;
import
org.apache.geode.internal.protocol.protobuf.v1.serialization.exception.EncodingException;
@@ -83,16 +82,6 @@ public abstract class ProtobufUtilities {
}
/**
- * This will convert a ProtobufErrorCode to a BasicTypes.ErrorCode for
protobuf
- *
- * @param errorCode - incoming ProtobufErrorCode
- * @return matching protobuf error code
- */
- public static BasicTypes.ErrorCode getProtobufErrorCode(ProtobufErrorCode
errorCode) {
- return BasicTypes.ErrorCode.forNumber(errorCode.codeValue);
- }
-
- /**
* @return a Protobuf BasicTypes.Region message that represents the {@link
Region}
*/
diff --git
a/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/ErrorCodesJUnitTest.java
b/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/ErrorCodesJUnitTest.java
deleted file mode 100644
index 427a0ab..0000000
---
a/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/ErrorCodesJUnitTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.geode.internal.protocol.protobuf.v1;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.test.junit.categories.UnitTest;
-
-@Category(UnitTest.class)
-public class ErrorCodesJUnitTest {
- @Test
- public void testProtobufErrorCodesMatchProtocolErrorCodes() {
- BasicTypes.ErrorCode[] protobufErrorCodes = BasicTypes.ErrorCode.values();
- ProtobufErrorCode[] protocolErrorCodes = ProtobufErrorCode.values();
-
- // These arrays should identical except the protobuf is required to have a
0 value, and defines
- // an UNRECOGNIZED entry
- assertEquals(protobufErrorCodes.length - 2, protocolErrorCodes.length);
- for (int i = 0; i < protobufErrorCodes.length; ++i) {
- if (i == 0) {
- assertEquals(BasicTypes.ErrorCode.INVALID_ERROR_CODE,
protobufErrorCodes[i]);
- } else if (i == protobufErrorCodes.length - 1) {
- assertEquals(BasicTypes.ErrorCode.UNRECOGNIZED, protobufErrorCodes[i]);
- } else {
- assertEquals(protobufErrorCodes[i].getNumber(), protocolErrorCodes[i -
1].codeValue);
- }
- }
- }
-}
--
To stop receiving notification emails like this one, please contact
[email protected].