You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/06/04 06:45:10 UTC

[GitHub] [servicecomb-java-chassis] wujimin opened a new pull request #1816: [SCB-1982] add validator filter

wujimin opened a new pull request #1816:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1816


   


----------------------------------------------------------------
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] [servicecomb-java-chassis] coveralls commented on pull request #1816: [SCB-1982] add validator filter

Posted by GitBox <gi...@apache.org>.
coveralls commented on pull request #1816:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1816#issuecomment-638686422


   
   [![Coverage Status](https://coveralls.io/builds/31231651/badge)](https://coveralls.io/builds/31231651)
   
   Coverage decreased (-0.01%) to 86.433% when pulling **92eb6612c5253dd71b675173268b2ca37788f45a on wujimin:SCB-1982-add-validator-filter** into **8d06545dade69912815f18603e32da9b0f5227ba on apache:master**.
   


----------------------------------------------------------------
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] [servicecomb-java-chassis] liubao68 merged pull request #1816: [SCB-1982] add validator filter

Posted by GitBox <gi...@apache.org>.
liubao68 merged pull request #1816:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1816


   


----------------------------------------------------------------
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] [servicecomb-java-chassis] coveralls edited a comment on pull request #1816: [SCB-1982] add validator filter

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #1816:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1816#issuecomment-638686422


   
   [![Coverage Status](https://coveralls.io/builds/31252266/badge)](https://coveralls.io/builds/31252266)
   
   Coverage decreased (-0.006%) to 86.3% when pulling **c3ad6770e40b3a792bbdc170f6f513401f6ebfe6 on wujimin:SCB-1982-add-validator-filter** into **9bb31d54c14060fc5e703cbc4ee7c08c73ed82ff on apache:master**.
   


----------------------------------------------------------------
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] [servicecomb-java-chassis] wujimin commented on a change in pull request #1816: [SCB-1982] add validator filter

Posted by GitBox <gi...@apache.org>.
wujimin commented on a change in pull request #1816:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1816#discussion_r435642189



##########
File path: core/src/main/java/org/apache/servicecomb/core/filter/impl/ParameterValidatorFilter.java
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.servicecomb.core.filter.impl;
+
+import static org.apache.servicecomb.swagger.invocation.InvocationType.PRODUCER;
+
+import java.lang.reflect.Method;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.ConstraintViolationException;
+import javax.validation.Validation;
+import javax.validation.ValidatorFactory;
+import javax.validation.executable.ExecutableValidator;
+import javax.validation.groups.Default;
+
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.core.filter.Filter;
+import org.apache.servicecomb.core.filter.FilterMeta;
+import org.apache.servicecomb.core.filter.FilterNode;
+import org.apache.servicecomb.foundation.common.utils.AsyncUtils;
+import org.apache.servicecomb.swagger.engine.SwaggerProducerOperation;
+import org.apache.servicecomb.swagger.invocation.Response;
+import org.hibernate.validator.HibernateValidator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.netflix.config.DynamicBooleanProperty;
+import com.netflix.config.DynamicPropertyFactory;
+
+@FilterMeta(name = "validator", invocationType = PRODUCER)
+public class ParameterValidatorFilter implements Filter {
+  private static final Logger LOGGER = LoggerFactory.getLogger(ParameterValidatorFilter.class);
+
+  private static final String PARAM_VALIDATION_ENABLED = "servicecomb.filters.validator.enabled";
+
+  private ExecutableValidator validator;
+
+  private final DynamicBooleanProperty paramValidationEnabled = DynamicPropertyFactory.getInstance()
+      .getBooleanProperty(PARAM_VALIDATION_ENABLED, false);
+
+  public ParameterValidatorFilter() {
+    paramValidationEnabled
+        .addCallback(() -> LOGGER.info("{} changed to {}", PARAM_VALIDATION_ENABLED, paramValidationEnabled.get()));

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.

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



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #1816: [SCB-1982] add validator filter

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #1816:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1816#discussion_r435187709



##########
File path: core/src/main/java/org/apache/servicecomb/core/filter/impl/ParameterValidatorFilter.java
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.servicecomb.core.filter.impl;
+
+import static org.apache.servicecomb.swagger.invocation.InvocationType.PRODUCER;
+
+import java.lang.reflect.Method;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.ConstraintViolationException;
+import javax.validation.Validation;
+import javax.validation.ValidatorFactory;
+import javax.validation.executable.ExecutableValidator;
+import javax.validation.groups.Default;
+
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.core.filter.Filter;
+import org.apache.servicecomb.core.filter.FilterMeta;
+import org.apache.servicecomb.core.filter.FilterNode;
+import org.apache.servicecomb.foundation.common.utils.AsyncUtils;
+import org.apache.servicecomb.swagger.engine.SwaggerProducerOperation;
+import org.apache.servicecomb.swagger.invocation.Response;
+import org.hibernate.validator.HibernateValidator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.netflix.config.DynamicBooleanProperty;
+import com.netflix.config.DynamicPropertyFactory;
+
+@FilterMeta(name = "validator", invocationType = PRODUCER)
+public class ParameterValidatorFilter implements Filter {
+  private static final Logger LOGGER = LoggerFactory.getLogger(ParameterValidatorFilter.class);
+
+  private static final String PARAM_VALIDATION_ENABLED = "servicecomb.filters.validator.enabled";
+
+  private ExecutableValidator validator;
+
+  private final DynamicBooleanProperty paramValidationEnabled = DynamicPropertyFactory.getInstance()
+      .getBooleanProperty(PARAM_VALIDATION_ENABLED, false);
+
+  public ParameterValidatorFilter() {
+    paramValidationEnabled
+        .addCallback(() -> LOGGER.info("{} changed to {}", PARAM_VALIDATION_ENABLED, paramValidationEnabled.get()));

Review comment:
       seams no need to add callback. paramValidationEnabled only used in initialization(Filter enable apply to initinization too). 




----------------------------------------------------------------
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] [servicecomb-java-chassis] wujimin commented on a change in pull request #1816: [SCB-1982] add validator filter

Posted by GitBox <gi...@apache.org>.
wujimin commented on a change in pull request #1816:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1816#discussion_r435630825



##########
File path: core/src/main/java/org/apache/servicecomb/core/filter/impl/ParameterValidatorFilter.java
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.servicecomb.core.filter.impl;
+
+import static org.apache.servicecomb.swagger.invocation.InvocationType.PRODUCER;
+
+import java.lang.reflect.Method;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.ConstraintViolationException;
+import javax.validation.Validation;
+import javax.validation.ValidatorFactory;
+import javax.validation.executable.ExecutableValidator;
+import javax.validation.groups.Default;
+
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.core.filter.Filter;
+import org.apache.servicecomb.core.filter.FilterMeta;
+import org.apache.servicecomb.core.filter.FilterNode;
+import org.apache.servicecomb.foundation.common.utils.AsyncUtils;
+import org.apache.servicecomb.swagger.engine.SwaggerProducerOperation;
+import org.apache.servicecomb.swagger.invocation.Response;
+import org.hibernate.validator.HibernateValidator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.netflix.config.DynamicBooleanProperty;
+import com.netflix.config.DynamicPropertyFactory;
+
+@FilterMeta(name = "validator", invocationType = PRODUCER)
+public class ParameterValidatorFilter implements Filter {
+  private static final Logger LOGGER = LoggerFactory.getLogger(ParameterValidatorFilter.class);
+
+  private static final String PARAM_VALIDATION_ENABLED = "servicecomb.filters.validator.enabled";
+
+  private ExecutableValidator validator;
+
+  private final DynamicBooleanProperty paramValidationEnabled = DynamicPropertyFactory.getInstance()
+      .getBooleanProperty(PARAM_VALIDATION_ENABLED, false);
+
+  public ParameterValidatorFilter() {
+    paramValidationEnabled
+        .addCallback(() -> LOGGER.info("{} changed to {}", PARAM_VALIDATION_ENABLED, paramValidationEnabled.get()));

Review comment:
       ok, only add when 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.

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