You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/04/15 11:16:46 UTC

[GitHub] [camel] davsclaus commented on a change in pull request #5373: Feature/fix zipkin spans alternate

davsclaus commented on a change in pull request #5373:
URL: https://github.com/apache/camel/pull/5373#discussion_r613975618



##########
File path: core/camel-api/src/main/java/org/apache/camel/CamelCopySafeProperty.java
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.camel;
+
+/**
+ *
+ * @author     Samrat.Dhillon
+ *
+ * @param  <T>
+ *
+ *             Interface that allows safe copy of property value object when creating copy of Exchange objects. Classes
+ *             implementing this interface are responsible for creating deep copy of the property value object.
+ */
+public interface CamelCopySafeProperty<T> {
+
+    CamelCopySafeProperty<T> safeCopy();

Review comment:
       Add javadoc here, as its part of camel-api which we should have documented

##########
File path: core/camel-api/src/main/java/org/apache/camel/CamelCopySafeProperty.java
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.camel;
+
+/**
+ *
+ * @author     Samrat.Dhillon
+ *
+ * @param  <T>
+ *
+ *             Interface that allows safe copy of property value object when creating copy of Exchange objects. Classes

Review comment:
       Can you cleanup the javadoc of this

##########
File path: core/camel-api/src/main/java/org/apache/camel/CamelCopySafeProperty.java
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.camel;
+
+/**
+ *
+ * @author     Samrat.Dhillon
+ *
+ * @param  <T>
+ *
+ *             Interface that allows safe copy of property value object when creating copy of Exchange objects. Classes
+ *             implementing this interface are responsible for creating deep copy of the property value object.
+ */
+public interface CamelCopySafeProperty<T> {

Review comment:
       Remove Camel in the name, and maybe `SafeCopyProperty` is a bit better name

##########
File path: core/camel-api/src/main/java/org/apache/camel/ExtendedExchange.java
##########
@@ -204,4 +204,22 @@
      */
     void setDefaultConsumerCallback(AsyncCallback callback);
 
+    /**
+     * Method to set properties which for which deep copies can be created

Review comment:
       Polish javadoc, and same for method below

##########
File path: core/camel-api/src/main/java/org/apache/camel/CamelCopySafeProperty.java
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.camel;
+
+/**
+ *
+ * @author     Samrat.Dhillon

Review comment:
       Please remove author tags

##########
File path: core/camel-support/src/main/java/org/apache/camel/support/AbstractExchange.java
##########
@@ -886,4 +912,32 @@ public String toString() {
         }
     }
 
+    @Override
+    public void setCopySafeProperty(String key, CamelCopySafeProperty<?> value) {
+        if (value != null) {
+            // avoid the NullPointException
+            if (copySafeProperties == null) {
+                this.copySafeProperties = new ConcurrentHashMap<>(2);
+            }
+            copySafeProperties.put(key, value);
+        } else if (copySafeProperties != null) {
+            // if the value is null, we just remove the key from the map
+            copySafeProperties.remove(key);
+        }
+
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T> T getCopySafeProperty(String key, Class<T> type) {
+
+        Object value = getCopySafeProperties().get(key);

Review comment:
       Optimize to check if there is any properties at all (ie its null) to then return null quickly




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