You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/08/24 13:57:50 UTC

[GitHub] [shardingsphere-elasticjob] TeslaCN opened a new pull request #1404: Improve Serializer Factory

TeslaCN opened a new pull request #1404:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1404


   Ref #1284 
   
   Changes proposed in this pull request:
   - Fail fast if (de)serializer not found.
   


----------------------------------------------------------------
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] [shardingsphere-elasticjob] Technoboy- commented on a change in pull request #1404: Improve Serializer Factory

Posted by GitBox <gi...@apache.org>.
Technoboy- commented on a change in pull request #1404:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1404#discussion_r475660298



##########
File path: elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/serializer/ResponseBodySerializerNotFoundException.java
##########
@@ -0,0 +1,30 @@
+/*
+ * 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.shardingsphere.elasticjob.restful.serializer;
+
+import java.text.MessageFormat;
+
+/**
+ * {@link ResponseBodySerializer} not found for specific MIME type.
+ */
+public class ResponseBodySerializerNotFoundException extends RuntimeException {

Review comment:
       Add final




----------------------------------------------------------------
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] [shardingsphere-elasticjob] terrymanu commented on a change in pull request #1404: Improve Serializer Factory

Posted by GitBox <gi...@apache.org>.
terrymanu commented on a change in pull request #1404:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1404#discussion_r475658949



##########
File path: elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/serializer/ResponseBodySerializerFactory.java
##########
@@ -84,7 +84,10 @@ public static ResponseBodySerializer getResponseBodySerializer(final String cont
                 serializer = RESPONSE_BODY_SERIALIZERS.get(contentType);
             }
         }
-        return serializer != MISSING_SERIALIZER ? serializer : null;
+        if (MISSING_SERIALIZER == serializer) {
+            throw new ResponseBodySerializerNotFoundException(contentType);
+        }
+        return serializer;

Review comment:
       The result variable should named as `result`

##########
File path: elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/deserializer/RequestBodyDeserializerFactory.java
##########
@@ -84,7 +84,10 @@ public static RequestBodyDeserializer getRequestBodyDeserializer(final String co
                 deserializer = REQUEST_BODY_DESERIALIZERS.get(contentType);
             }
         }
-        return deserializer != MISSING_DESERIALIZER ? deserializer : null;
+        if (MISSING_DESERIALIZER == deserializer) {
+            throw new RequestBodyDeserializerNotFoundException(contentType);
+        }
+        return deserializer;

Review comment:
       The result variable should named as `result`

##########
File path: elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/deserializer/RequestBodyDeserializerNotFoundException.java
##########
@@ -0,0 +1,30 @@
+/*
+ * 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.shardingsphere.elasticjob.restful.deserializer;
+
+import java.text.MessageFormat;
+
+/**
+ * {@link RequestBodyDeserializer} not found for specific MIME type.
+ */
+public class RequestBodyDeserializerNotFoundException extends RuntimeException {

Review comment:
       Please add final if class is not design for extension




----------------------------------------------------------------
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] [shardingsphere-elasticjob] Technoboy- merged pull request #1404: Improve Serializer Factory

Posted by GitBox <gi...@apache.org>.
Technoboy- merged pull request #1404:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1404


   


----------------------------------------------------------------
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