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/07/15 07:03:33 UTC
[GitHub] [camel-quarkus] JiriOndrusek opened a new pull request #2904: Use of serialization feature of Quakus (fro Sql and Minio)
JiriOndrusek opened a new pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904
fixes https://github.com/apache/camel-quarkus/issues/2755
**! Draft !**
In his change I propose registration for serialization of several basic classes. But because this is not required by the most of the extensions, I suppose that creating a buildItem and based registration on it, would be better. @ppalaga @jamesnetherton WDYT?
Another problem is `BigInteger`, which doesn't work - I have to find why.
<!-- Uncomment and fill this section if your PR is not trivial
[ ] An issue should be filed for the change unless this is a trivial change (fixing a typo or similar). One issue should ideally be fixed by not more than one commit and the other way round, each commit should fix just one issue, without pulling in other changes.
[ ] Each commit in the pull request should have a meaningful and properly spelled subject line and body. Copying the title of the associated issue is typically enough. Please include the issue number in the commit message prefixed by #.
[ ] The pull request description should explain what the pull request does, how, and why. If the info is available in the associated issue or some other external document, a link is enough.
[ ] Phrases like Fix #<issueNumber> or Fixes #<issueNumber> will auto-close the named issue upon merging the pull request. Using them is typically a good idea.
[ ] Please run mvn process-resources -Pformat (and amend the changes if necessary) before sending the pull request.
[ ] Contributor guide is your good friend: https://camel.apache.org/camel-quarkus/latest/contributor-guide.html
-->
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#discussion_r672889720
##########
File path: integration-test-groups/foundation/core/src/main/java/org/apache/camel/quarkus/core/MySerializationObject.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.quarkus.core;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.time.Instant;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection(serialization = true)
+public class MySerializationObject implements Serializable {
+
+ private Long _long;
+ private Integer _integer;
+ private Date _date;
+ private String _string;
+ private Float _float;
+ private Double _double;
+ private BigInteger _bigInteger;
+ private HashMap _hashMap;
+ private LinkedHashMap _linkedHashMap;
+ private Character _char;
+ private Boolean _boolean;
+ private Byte _byte;
+
+ public void initValues() {
+ _long = 1l;
+ _integer = 1;
+ _date = Date.from(Instant.now());
+ _string = "A";
+ _float = Float.valueOf(1);
+ _double = Double.valueOf(1);
+ _bigInteger = BigInteger.valueOf(1);
+ _hashMap = new HashMap();
+ _hashMap.put(1, "one");
+ _linkedHashMap = new LinkedHashMap();
+ _linkedHashMap.put(1, "one");
+ _char = Character.valueOf('a');
+ _boolean = Boolean.FALSE;
+ _byte = Byte.valueOf("1");
+ }
+
+ public boolean isNutNull() {
+ return _long != null &&
+ _integer != null &&
+ _date != null &&
+ _string != null &&
+ _float != null &&
+ _double != null &&
+ _bigInteger != null &&
+ _hashMap != null &&
+ _linkedHashMap != null &&
+ _char != null &&
+ _boolean != null &&
+ _byte != null;
+ }
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] jamesnetherton commented on pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#issuecomment-883109887
Is there any work remaining on this one? It'd be good to get it merged ASAP as there's a few other things that depend on it.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] ppalaga merged pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
ppalaga merged pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#discussion_r672889403
##########
File path: docs/modules/ROOT/pages/reference/extensions/core.adoc
##########
@@ -224,6 +245,13 @@ A comma separated list of Ant-path style patterns to match class names that shou
| `string`
|
+|icon:lock[title=Fixed at build time] [[quarkus.camel.native.reflection.serialization-enabled]]`link:#quarkus.camel.native.reflection.serialization-enabled[quarkus.camel.native.reflection.serialization-enabled]`
+
+If `true`, basic classes are registered for serialization; otherwise Java serialization will not work in native mode.
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#issuecomment-883118884
Please leave me about an hour to add changes pointed by @ppalaga
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] jamesnetherton commented on pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#issuecomment-882398105
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] jamesnetherton commented on a change in pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on a change in pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#discussion_r672942129
##########
File path: docs/modules/ROOT/pages/user-guide/native-mode.adoc
##########
@@ -111,3 +111,28 @@ in {@code application.properties} - e.g.
quarkus.index-dependency.commons-lang3.group-id = org.apache.commons
quarkus.index-dependency.commons-lang3.artifact-id = commons-lang3
----
+
+[[serialization]]
+== Registration for serialization
+
+If serialization support is requested via `quarkus.camel.native.reflection.serialization-enabled`, following classes are registered for serialization:
+
+* `java.lang.Boolean`
+* `java.lang.Byte`
+* `java.lang.Character`
+* `java.lang.Float`
+* `java.lang.Double`
+* `java.lang.Integer`
+* `java.lang.Long`
+* `java.lang.Number`
+* `java.lang.String`
+* `java.math.BigInteger`
+* `java.util.Date`
+* `java.util.HashMap`
+* `java.util.LinkedHashMap`
+* `org.apache.camel.support.DefaultExchangeHolder`
+
+Developers can configure classes for serialization via the serialization configuration file
Review comment:
We can address this in a follow up issue / PR but we shouldn't we mention `@RegisterForReflection(serialization = true)` as the preferred way of registering user classes for serialization? `-H:SerializationConfigurationResources` is kind of a low level option which should be avoided if possible.
Maybe this has been discussed elsewhere already but I wonder if we should introduce a config property that lets you configure arbitrary classes for serialization like we have for reflection?
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#discussion_r672279681
##########
File path: extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/spi/CamelSerializationBuildItem.java
##########
@@ -0,0 +1,25 @@
+/*
+ * 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.quarkus.core.deployment.spi;
+
+import io.quarkus.builder.item.MultiBuildItem;
+
+/**
+ * A build item that does not carry any data but it is used to signal that registration for serialization is requested.
Review comment:
I'll do it.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#discussion_r672281023
##########
File path: integration-test-groups/foundation/core/src/main/java/org/apache/camel/quarkus/core/MySerializationObject.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.quarkus.core;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.time.Instant;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection(serialization = true)
+public class MySerializationObject implements Serializable {
+
+ private Long _long;
+ private Integer _integer;
+ private Date _date;
+ private String _string;
+ private Float _float;
+ private Double _double;
+ private BigInteger _bigInteger;
+ private HashMap _hashMap;
+ private LinkedHashMap _linkedHashMap;
+ private Character _char;
+ private Boolean _boolean;
+ private Byte _byte;
+
+ public void initValues() {
+ _long = 1l;
+ _integer = 1;
+ _date = Date.from(Instant.now());
+ _string = "A";
+ _float = Float.valueOf(1);
+ _double = Double.valueOf(1);
+ _bigInteger = BigInteger.valueOf(1);
+ _hashMap = new HashMap();
+ _hashMap.put(1, "one");
+ _linkedHashMap = new LinkedHashMap();
+ _linkedHashMap.put(1, "one");
+ _char = Character.valueOf('a');
+ _boolean = Boolean.FALSE;
+ _byte = Byte.valueOf("1");
+ }
+
+ public boolean isNutNull() {
+ return _long != null &&
+ _integer != null &&
+ _date != null &&
+ _string != null &&
+ _float != null &&
+ _double != null &&
+ _bigInteger != null &&
+ _hashMap != null &&
+ _linkedHashMap != null &&
+ _char != null &&
+ _boolean != null &&
+ _byte != null;
+ }
Review comment:
We can be more paranoid here. My idea was, that if serialization ends without an error, it works. (this should be probably covered somewhere in GraalVM tests). But no problem with being more strict and checking the real values.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#issuecomment-883118884
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] zbendhiba commented on pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
zbendhiba commented on pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#issuecomment-882377404
> btw we should really add a task to revisit DefaultExchangeHolder as it has been designed when serialization was cool but now it should be better to use json/avro/protobof
+1
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#issuecomment-882437059
I'll rebase
and here is an issue about `DefaultExchangeHolder` - https://issues.apache.org/jira/browse/CAMEL-16805
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#issuecomment-883178304
@jamesnetherton All items are fixed. There is no more remaining work on this PR.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#discussion_r672278583
##########
File path: docs/modules/ROOT/pages/reference/extensions/core.adoc
##########
@@ -104,6 +104,27 @@ camel.beans.customBeanWithSetterInjection.counter = 123
As such, the class `PropertiesCustomBeanWithSetterInjection` needs to be link:https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection[registered for reflection], note that field access could be omitted in this case.
+==== Serialization in native mode
+
+If serialization support is requested via `quarkus.camel.native.reflection.serialization-enabled`, following classes are registered for serialization:
+
+* `java.lang.Boolean`
+* `java.lang.Byte`
+* `java.lang.Character`
+* `java.lang.Float`
+* `java.lang.Double`
+* `java.lang.Integer`
+* `java.lang.Long`
+* `java.lang.Number`
+* `java.lang.String`
+* `java.math.BigInteger`
+* `java.util.Date`
+* `java.util.HashMap`
+* `java.util.LinkedHashMap`
+* `org.apache.camel.support.DefaultExchangeHolder`
+
+Developers can register other classes for serialization via the `ReflectiveClassBuildItem`.
Review comment:
yes, you are right . Native-mode.adoc seems to be better place to write about it and I'll try to omit the buildItem and add link to the native registration via properties.
##########
File path: docs/modules/ROOT/pages/reference/extensions/core.adoc
##########
@@ -224,6 +245,13 @@ A comma separated list of Ant-path style patterns to match class names that shou
| `string`
|
+|icon:lock[title=Fixed at build time] [[quarkus.camel.native.reflection.serialization-enabled]]`link:#quarkus.camel.native.reflection.serialization-enabled[quarkus.camel.native.reflection.serialization-enabled]`
+
+If `true`, basic classes are registered for serialization; otherwise Java serialization will not work in native mode.
Review comment:
Add listing classes - I thought that link to the list would be enough, but I can list them here as well.
Yes it is a overstatement, I'll change it.
##########
File path: extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/spi/CamelSerializationBuildItem.java
##########
@@ -0,0 +1,25 @@
+/*
+ * 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.quarkus.core.deployment.spi;
+
+import io.quarkus.builder.item.MultiBuildItem;
+
+/**
+ * A build item that does not carry any data but it is used to signal that registration for serialization is requested.
Review comment:
I'll do it.
##########
File path: integration-test-groups/foundation/core/src/main/java/org/apache/camel/quarkus/core/MySerializationObject.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.quarkus.core;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.time.Instant;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection(serialization = true)
+public class MySerializationObject implements Serializable {
+
+ private Long _long;
+ private Integer _integer;
+ private Date _date;
+ private String _string;
+ private Float _float;
+ private Double _double;
+ private BigInteger _bigInteger;
+ private HashMap _hashMap;
+ private LinkedHashMap _linkedHashMap;
+ private Character _char;
+ private Boolean _boolean;
+ private Byte _byte;
+
+ public void initValues() {
+ _long = 1l;
+ _integer = 1;
+ _date = Date.from(Instant.now());
+ _string = "A";
+ _float = Float.valueOf(1);
+ _double = Double.valueOf(1);
+ _bigInteger = BigInteger.valueOf(1);
+ _hashMap = new HashMap();
+ _hashMap.put(1, "one");
+ _linkedHashMap = new LinkedHashMap();
+ _linkedHashMap.put(1, "one");
+ _char = Character.valueOf('a');
+ _boolean = Boolean.FALSE;
+ _byte = Byte.valueOf("1");
+ }
+
+ public boolean isNutNull() {
+ return _long != null &&
+ _integer != null &&
+ _date != null &&
+ _string != null &&
+ _float != null &&
+ _double != null &&
+ _bigInteger != null &&
+ _hashMap != null &&
+ _linkedHashMap != null &&
+ _char != null &&
+ _boolean != null &&
+ _byte != null;
+ }
Review comment:
We can be more paranoid here. My idea was, that if serialization ends without an error, it works. (this should be probably covered somewhere in GraalVM tests). But no problem with being more strict and check the real values.
##########
File path: integration-test-groups/foundation/core/src/main/java/org/apache/camel/quarkus/core/MySerializationObject.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.quarkus.core;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.time.Instant;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection(serialization = true)
+public class MySerializationObject implements Serializable {
+
+ private Long _long;
+ private Integer _integer;
+ private Date _date;
+ private String _string;
+ private Float _float;
+ private Double _double;
+ private BigInteger _bigInteger;
+ private HashMap _hashMap;
+ private LinkedHashMap _linkedHashMap;
+ private Character _char;
+ private Boolean _boolean;
+ private Byte _byte;
+
+ public void initValues() {
+ _long = 1l;
+ _integer = 1;
+ _date = Date.from(Instant.now());
+ _string = "A";
+ _float = Float.valueOf(1);
+ _double = Double.valueOf(1);
+ _bigInteger = BigInteger.valueOf(1);
+ _hashMap = new HashMap();
+ _hashMap.put(1, "one");
+ _linkedHashMap = new LinkedHashMap();
+ _linkedHashMap.put(1, "one");
+ _char = Character.valueOf('a');
+ _boolean = Boolean.FALSE;
+ _byte = Byte.valueOf("1");
+ }
+
+ public boolean isNutNull() {
+ return _long != null &&
+ _integer != null &&
+ _date != null &&
+ _string != null &&
+ _float != null &&
+ _double != null &&
+ _bigInteger != null &&
+ _hashMap != null &&
+ _linkedHashMap != null &&
+ _char != null &&
+ _boolean != null &&
+ _byte != null;
+ }
Review comment:
We can be more paranoid here. My idea was, that if serialization ends without an error, it works. (this should be probably covered somewhere in GraalVM tests). But no problem with being more strict and checking the real values.
##########
File path: docs/modules/ROOT/pages/reference/extensions/core.adoc
##########
@@ -104,6 +104,27 @@ camel.beans.customBeanWithSetterInjection.counter = 123
As such, the class `PropertiesCustomBeanWithSetterInjection` needs to be link:https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection[registered for reflection], note that field access could be omitted in this case.
+==== Serialization in native mode
+
+If serialization support is requested via `quarkus.camel.native.reflection.serialization-enabled`, following classes are registered for serialization:
+
+* `java.lang.Boolean`
+* `java.lang.Byte`
+* `java.lang.Character`
+* `java.lang.Float`
+* `java.lang.Double`
+* `java.lang.Integer`
+* `java.lang.Long`
+* `java.lang.Number`
+* `java.lang.String`
+* `java.math.BigInteger`
+* `java.util.Date`
+* `java.util.HashMap`
+* `java.util.LinkedHashMap`
+* `org.apache.camel.support.DefaultExchangeHolder`
+
+Developers can register other classes for serialization via the `ReflectiveClassBuildItem`.
Review comment:
done
##########
File path: extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/spi/CamelSerializationBuildItem.java
##########
@@ -0,0 +1,25 @@
+/*
+ * 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.quarkus.core.deployment.spi;
+
+import io.quarkus.builder.item.MultiBuildItem;
+
+/**
+ * A build item that does not carry any data but it is used to signal that registration for serialization is requested.
Review comment:
done
##########
File path: docs/modules/ROOT/pages/reference/extensions/core.adoc
##########
@@ -224,6 +245,13 @@ A comma separated list of Ant-path style patterns to match class names that shou
| `string`
|
+|icon:lock[title=Fixed at build time] [[quarkus.camel.native.reflection.serialization-enabled]]`link:#quarkus.camel.native.reflection.serialization-enabled[quarkus.camel.native.reflection.serialization-enabled]`
+
+If `true`, basic classes are registered for serialization; otherwise Java serialization will not work in native mode.
Review comment:
done
##########
File path: integration-test-groups/foundation/core/src/main/java/org/apache/camel/quarkus/core/MySerializationObject.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.quarkus.core;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.time.Instant;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection(serialization = true)
+public class MySerializationObject implements Serializable {
+
+ private Long _long;
+ private Integer _integer;
+ private Date _date;
+ private String _string;
+ private Float _float;
+ private Double _double;
+ private BigInteger _bigInteger;
+ private HashMap _hashMap;
+ private LinkedHashMap _linkedHashMap;
+ private Character _char;
+ private Boolean _boolean;
+ private Byte _byte;
+
+ public void initValues() {
+ _long = 1l;
+ _integer = 1;
+ _date = Date.from(Instant.now());
+ _string = "A";
+ _float = Float.valueOf(1);
+ _double = Double.valueOf(1);
+ _bigInteger = BigInteger.valueOf(1);
+ _hashMap = new HashMap();
+ _hashMap.put(1, "one");
+ _linkedHashMap = new LinkedHashMap();
+ _linkedHashMap.put(1, "one");
+ _char = Character.valueOf('a');
+ _boolean = Boolean.FALSE;
+ _byte = Byte.valueOf("1");
+ }
+
+ public boolean isNutNull() {
+ return _long != null &&
+ _integer != null &&
+ _date != null &&
+ _string != null &&
+ _float != null &&
+ _double != null &&
+ _bigInteger != null &&
+ _hashMap != null &&
+ _linkedHashMap != null &&
+ _char != null &&
+ _boolean != null &&
+ _byte != null;
+ }
Review comment:
done
##########
File path: docs/modules/ROOT/pages/user-guide/native-mode.adoc
##########
@@ -111,3 +111,28 @@ in {@code application.properties} - e.g.
quarkus.index-dependency.commons-lang3.group-id = org.apache.commons
quarkus.index-dependency.commons-lang3.artifact-id = commons-lang3
----
+
+[[serialization]]
+== Registration for serialization
+
+If serialization support is requested via `quarkus.camel.native.reflection.serialization-enabled`, following classes are registered for serialization:
+
+* `java.lang.Boolean`
+* `java.lang.Byte`
+* `java.lang.Character`
+* `java.lang.Float`
+* `java.lang.Double`
+* `java.lang.Integer`
+* `java.lang.Long`
+* `java.lang.Number`
+* `java.lang.String`
+* `java.math.BigInteger`
+* `java.util.Date`
+* `java.util.HashMap`
+* `java.util.LinkedHashMap`
+* `org.apache.camel.support.DefaultExchangeHolder`
+
+Developers can configure classes for serialization via the serialization configuration file
Review comment:
Oh I understand one previous comment wrongly, I'll reword it with @RegisterForReflection(serialization = true)
##########
File path: docs/modules/ROOT/pages/user-guide/native-mode.adoc
##########
@@ -111,3 +111,28 @@ in {@code application.properties} - e.g.
quarkus.index-dependency.commons-lang3.group-id = org.apache.commons
quarkus.index-dependency.commons-lang3.artifact-id = commons-lang3
----
+
+[[serialization]]
+== Registration for serialization
+
+If serialization support is requested via `quarkus.camel.native.reflection.serialization-enabled`, following classes are registered for serialization:
+
+* `java.lang.Boolean`
+* `java.lang.Byte`
+* `java.lang.Character`
+* `java.lang.Float`
+* `java.lang.Double`
+* `java.lang.Integer`
+* `java.lang.Long`
+* `java.lang.Number`
+* `java.lang.String`
+* `java.math.BigInteger`
+* `java.util.Date`
+* `java.util.HashMap`
+* `java.util.LinkedHashMap`
+* `org.apache.camel.support.DefaultExchangeHolder`
+
+Developers can configure classes for serialization via the serialization configuration file
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] jamesnetherton commented on pull request #2904: Use of serialization feature of Quakus (fro Sql and Minio)
Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#issuecomment-880458121
> I suppose that creating a buildItem and based registration on it
Yeah, that's how I would have implemented it. Otherwise every extension that wants serialization support has to duplicate the required steps.
I guess the registration of the basic Java types ideally belongs in Quarkus itself.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] jamesnetherton commented on a change in pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on a change in pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#discussion_r672942129
##########
File path: docs/modules/ROOT/pages/user-guide/native-mode.adoc
##########
@@ -111,3 +111,28 @@ in {@code application.properties} - e.g.
quarkus.index-dependency.commons-lang3.group-id = org.apache.commons
quarkus.index-dependency.commons-lang3.artifact-id = commons-lang3
----
+
+[[serialization]]
+== Registration for serialization
+
+If serialization support is requested via `quarkus.camel.native.reflection.serialization-enabled`, following classes are registered for serialization:
+
+* `java.lang.Boolean`
+* `java.lang.Byte`
+* `java.lang.Character`
+* `java.lang.Float`
+* `java.lang.Double`
+* `java.lang.Integer`
+* `java.lang.Long`
+* `java.lang.Number`
+* `java.lang.String`
+* `java.math.BigInteger`
+* `java.util.Date`
+* `java.util.HashMap`
+* `java.util.LinkedHashMap`
+* `org.apache.camel.support.DefaultExchangeHolder`
+
+Developers can configure classes for serialization via the serialization configuration file
Review comment:
We can address this in a follow up issue / PR but we shouldn't we mention `@RegisterForReflection(serialization = true)` as the preferred way of registering user classes for serialization? `-H:SerializationConfigurationResources` is kind of a low level option which should be avoided if possible.
Maybe this has been discussed elsewhere already but I wonder if we should introduce a config property that lets you configure arbitrary classes for serialization like we have for reflection?
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] zbendhiba commented on pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
zbendhiba commented on pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#issuecomment-882377404
> btw we should really add a task to revisit DefaultExchangeHolder as it has been designed when serialization was cool but now it should be better to use json/avro/protobof
+1
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek edited a comment on pull request #2904: Use of serialization feature of Quakus (fro Sql and Minio)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek edited a comment on pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#issuecomment-880462369
I agree that basic stuff would be in quarkus - in the future. (I plan to create a PR there)
But some stuff like `org.apache.camel.support.DefaultExchangeHolder` would stay here.
Thanks for your response!
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#discussion_r672278583
##########
File path: docs/modules/ROOT/pages/reference/extensions/core.adoc
##########
@@ -104,6 +104,27 @@ camel.beans.customBeanWithSetterInjection.counter = 123
As such, the class `PropertiesCustomBeanWithSetterInjection` needs to be link:https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection[registered for reflection], note that field access could be omitted in this case.
+==== Serialization in native mode
+
+If serialization support is requested via `quarkus.camel.native.reflection.serialization-enabled`, following classes are registered for serialization:
+
+* `java.lang.Boolean`
+* `java.lang.Byte`
+* `java.lang.Character`
+* `java.lang.Float`
+* `java.lang.Double`
+* `java.lang.Integer`
+* `java.lang.Long`
+* `java.lang.Number`
+* `java.lang.String`
+* `java.math.BigInteger`
+* `java.util.Date`
+* `java.util.HashMap`
+* `java.util.LinkedHashMap`
+* `org.apache.camel.support.DefaultExchangeHolder`
+
+Developers can register other classes for serialization via the `ReflectiveClassBuildItem`.
Review comment:
yes, you are right . Native-mode.adoc seems to be better place to write about it and I'll try to omit the buildItem and add link to the native registration via properties.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#issuecomment-882437059
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#discussion_r672260733
##########
File path: docs/modules/ROOT/pages/reference/extensions/core.adoc
##########
@@ -104,6 +104,27 @@ camel.beans.customBeanWithSetterInjection.counter = 123
As such, the class `PropertiesCustomBeanWithSetterInjection` needs to be link:https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection[registered for reflection], note that field access could be omitted in this case.
+==== Serialization in native mode
+
+If serialization support is requested via `quarkus.camel.native.reflection.serialization-enabled`, following classes are registered for serialization:
+
+* `java.lang.Boolean`
+* `java.lang.Byte`
+* `java.lang.Character`
+* `java.lang.Float`
+* `java.lang.Double`
+* `java.lang.Integer`
+* `java.lang.Long`
+* `java.lang.Number`
+* `java.lang.String`
+* `java.math.BigInteger`
+* `java.util.Date`
+* `java.util.HashMap`
+* `java.util.LinkedHashMap`
+* `org.apache.camel.support.DefaultExchangeHolder`
+
+Developers can register other classes for serialization via the `ReflectiveClassBuildItem`.
Review comment:
`ReflectiveClassBuildItem` is for extension developers and this is rather a part of user guide. I think we should better omit this sentence or mention some way how application devs can register additional classes for serialization. Don't we have a property for that? (Or I wonder whether `@RegisterForReflection` shouldn't be modify to allow that too?)
Wouldn't [native-mode.adoc](https://camel.apache.org/camel-quarkus/latest/user-guide/native-mode.html) be a better place for this whole section about Serialization in native mode?
##########
File path: docs/modules/ROOT/pages/reference/extensions/core.adoc
##########
@@ -224,6 +245,13 @@ A comma separated list of Ant-path style patterns to match class names that shou
| `string`
|
+|icon:lock[title=Fixed at build time] [[quarkus.camel.native.reflection.serialization-enabled]]`link:#quarkus.camel.native.reflection.serialization-enabled[quarkus.camel.native.reflection.serialization-enabled]`
+
+If `true`, basic classes are registered for serialization; otherwise Java serialization will not work in native mode.
Review comment:
It would be nice to list the classes here as well.
> otherwise Java serialization will not work in native mode.
Isn't that a bit of an overstatement? It would work, but only for the registered classes, no?
##########
File path: extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/spi/CamelSerializationBuildItem.java
##########
@@ -0,0 +1,25 @@
+/*
+ * 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.quarkus.core.deployment.spi;
+
+import io.quarkus.builder.item.MultiBuildItem;
+
+/**
+ * A build item that does not carry any data but it is used to signal that registration for serialization is requested.
Review comment:
```suggestion
* Signal that basic classes listed in {@code org.apache.camel.quarkus.core.deployment.CamelSerializationProcessor.baseSerializationClasses() should be registered for serialization.
```
##########
File path: integration-test-groups/foundation/core/src/main/java/org/apache/camel/quarkus/core/MySerializationObject.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.quarkus.core;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.time.Instant;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection(serialization = true)
+public class MySerializationObject implements Serializable {
+
+ private Long _long;
+ private Integer _integer;
+ private Date _date;
+ private String _string;
+ private Float _float;
+ private Double _double;
+ private BigInteger _bigInteger;
+ private HashMap _hashMap;
+ private LinkedHashMap _linkedHashMap;
+ private Character _char;
+ private Boolean _boolean;
+ private Byte _byte;
+
+ public void initValues() {
+ _long = 1l;
+ _integer = 1;
+ _date = Date.from(Instant.now());
+ _string = "A";
+ _float = Float.valueOf(1);
+ _double = Double.valueOf(1);
+ _bigInteger = BigInteger.valueOf(1);
+ _hashMap = new HashMap();
+ _hashMap.put(1, "one");
+ _linkedHashMap = new LinkedHashMap();
+ _linkedHashMap.put(1, "one");
+ _char = Character.valueOf('a');
+ _boolean = Boolean.FALSE;
+ _byte = Byte.valueOf("1");
+ }
+
+ public boolean isNutNull() {
+ return _long != null &&
+ _integer != null &&
+ _date != null &&
+ _string != null &&
+ _float != null &&
+ _double != null &&
+ _bigInteger != null &&
+ _hashMap != null &&
+ _linkedHashMap != null &&
+ _char != null &&
+ _boolean != null &&
+ _byte != null;
+ }
Review comment:
I'd vote for being more paranoid here - we should check whether the fields have the same values as set by `initValues()`
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] jamesnetherton commented on pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#issuecomment-883109887
Is there any work remaining on this one? It'd be good to get it merged ASAP as there's a few other things that depend on it.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] lburgazzoli commented on pull request #2904: Use of serialization feature of Quakus (fro Sql and Minio)
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#issuecomment-880483809
oh that's nice.
btw we should really add a task to revisit DefaultExchangeHolder as it has been designed when serialization was cool but now it should be better to use json/avro/protobof
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] jamesnetherton commented on a change in pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on a change in pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#discussion_r672942129
##########
File path: docs/modules/ROOT/pages/user-guide/native-mode.adoc
##########
@@ -111,3 +111,28 @@ in {@code application.properties} - e.g.
quarkus.index-dependency.commons-lang3.group-id = org.apache.commons
quarkus.index-dependency.commons-lang3.artifact-id = commons-lang3
----
+
+[[serialization]]
+== Registration for serialization
+
+If serialization support is requested via `quarkus.camel.native.reflection.serialization-enabled`, following classes are registered for serialization:
+
+* `java.lang.Boolean`
+* `java.lang.Byte`
+* `java.lang.Character`
+* `java.lang.Float`
+* `java.lang.Double`
+* `java.lang.Integer`
+* `java.lang.Long`
+* `java.lang.Number`
+* `java.lang.String`
+* `java.math.BigInteger`
+* `java.util.Date`
+* `java.util.HashMap`
+* `java.util.LinkedHashMap`
+* `org.apache.camel.support.DefaultExchangeHolder`
+
+Developers can configure classes for serialization via the serialization configuration file
Review comment:
We can address this in a follow up issue / PR but we shouldn't we mention `@RegisterForReflection(serialization = true)` as the preferred way of registering user classes for serialization? `-H:SerializationConfigurationResources` is kind of a low level option which should be avoided if possible.
Maybe this has been discussed elsewhere already but I wonder if we should introduce a config property that lets you configure arbitrary classes for serialization like we have for reflection?
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#discussion_r672888813
##########
File path: docs/modules/ROOT/pages/reference/extensions/core.adoc
##########
@@ -104,6 +104,27 @@ camel.beans.customBeanWithSetterInjection.counter = 123
As such, the class `PropertiesCustomBeanWithSetterInjection` needs to be link:https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection[registered for reflection], note that field access could be omitted in this case.
+==== Serialization in native mode
+
+If serialization support is requested via `quarkus.camel.native.reflection.serialization-enabled`, following classes are registered for serialization:
+
+* `java.lang.Boolean`
+* `java.lang.Byte`
+* `java.lang.Character`
+* `java.lang.Float`
+* `java.lang.Double`
+* `java.lang.Integer`
+* `java.lang.Long`
+* `java.lang.Number`
+* `java.lang.String`
+* `java.math.BigInteger`
+* `java.util.Date`
+* `java.util.HashMap`
+* `java.util.LinkedHashMap`
+* `org.apache.camel.support.DefaultExchangeHolder`
+
+Developers can register other classes for serialization via the `ReflectiveClassBuildItem`.
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#discussion_r672888985
##########
File path: extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/spi/CamelSerializationBuildItem.java
##########
@@ -0,0 +1,25 @@
+/*
+ * 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.quarkus.core.deployment.spi;
+
+import io.quarkus.builder.item.MultiBuildItem;
+
+/**
+ * A build item that does not carry any data but it is used to signal that registration for serialization is requested.
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#discussion_r672278583
##########
File path: docs/modules/ROOT/pages/reference/extensions/core.adoc
##########
@@ -104,6 +104,27 @@ camel.beans.customBeanWithSetterInjection.counter = 123
As such, the class `PropertiesCustomBeanWithSetterInjection` needs to be link:https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection[registered for reflection], note that field access could be omitted in this case.
+==== Serialization in native mode
+
+If serialization support is requested via `quarkus.camel.native.reflection.serialization-enabled`, following classes are registered for serialization:
+
+* `java.lang.Boolean`
+* `java.lang.Byte`
+* `java.lang.Character`
+* `java.lang.Float`
+* `java.lang.Double`
+* `java.lang.Integer`
+* `java.lang.Long`
+* `java.lang.Number`
+* `java.lang.String`
+* `java.math.BigInteger`
+* `java.util.Date`
+* `java.util.HashMap`
+* `java.util.LinkedHashMap`
+* `org.apache.camel.support.DefaultExchangeHolder`
+
+Developers can register other classes for serialization via the `ReflectiveClassBuildItem`.
Review comment:
yes, you are right . Native-mode.adoc seems to be better place to write about it and I'll try to omit the buildItem and add link to the native registration via properties.
##########
File path: docs/modules/ROOT/pages/reference/extensions/core.adoc
##########
@@ -224,6 +245,13 @@ A comma separated list of Ant-path style patterns to match class names that shou
| `string`
|
+|icon:lock[title=Fixed at build time] [[quarkus.camel.native.reflection.serialization-enabled]]`link:#quarkus.camel.native.reflection.serialization-enabled[quarkus.camel.native.reflection.serialization-enabled]`
+
+If `true`, basic classes are registered for serialization; otherwise Java serialization will not work in native mode.
Review comment:
Add listing classes - I thought that link to the list would be enough, but I can list them here as well.
Yes it is a overstatement, I'll change it.
##########
File path: extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/spi/CamelSerializationBuildItem.java
##########
@@ -0,0 +1,25 @@
+/*
+ * 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.quarkus.core.deployment.spi;
+
+import io.quarkus.builder.item.MultiBuildItem;
+
+/**
+ * A build item that does not carry any data but it is used to signal that registration for serialization is requested.
Review comment:
I'll do it.
##########
File path: integration-test-groups/foundation/core/src/main/java/org/apache/camel/quarkus/core/MySerializationObject.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.quarkus.core;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.time.Instant;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection(serialization = true)
+public class MySerializationObject implements Serializable {
+
+ private Long _long;
+ private Integer _integer;
+ private Date _date;
+ private String _string;
+ private Float _float;
+ private Double _double;
+ private BigInteger _bigInteger;
+ private HashMap _hashMap;
+ private LinkedHashMap _linkedHashMap;
+ private Character _char;
+ private Boolean _boolean;
+ private Byte _byte;
+
+ public void initValues() {
+ _long = 1l;
+ _integer = 1;
+ _date = Date.from(Instant.now());
+ _string = "A";
+ _float = Float.valueOf(1);
+ _double = Double.valueOf(1);
+ _bigInteger = BigInteger.valueOf(1);
+ _hashMap = new HashMap();
+ _hashMap.put(1, "one");
+ _linkedHashMap = new LinkedHashMap();
+ _linkedHashMap.put(1, "one");
+ _char = Character.valueOf('a');
+ _boolean = Boolean.FALSE;
+ _byte = Byte.valueOf("1");
+ }
+
+ public boolean isNutNull() {
+ return _long != null &&
+ _integer != null &&
+ _date != null &&
+ _string != null &&
+ _float != null &&
+ _double != null &&
+ _bigInteger != null &&
+ _hashMap != null &&
+ _linkedHashMap != null &&
+ _char != null &&
+ _boolean != null &&
+ _byte != null;
+ }
Review comment:
We can be more paranoid here. My idea was, that if serialization ends without an error, it works. (this should be probably covered somewhere in GraalVM tests). But no problem with being more strict and check the real values.
##########
File path: integration-test-groups/foundation/core/src/main/java/org/apache/camel/quarkus/core/MySerializationObject.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.quarkus.core;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.time.Instant;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection(serialization = true)
+public class MySerializationObject implements Serializable {
+
+ private Long _long;
+ private Integer _integer;
+ private Date _date;
+ private String _string;
+ private Float _float;
+ private Double _double;
+ private BigInteger _bigInteger;
+ private HashMap _hashMap;
+ private LinkedHashMap _linkedHashMap;
+ private Character _char;
+ private Boolean _boolean;
+ private Byte _byte;
+
+ public void initValues() {
+ _long = 1l;
+ _integer = 1;
+ _date = Date.from(Instant.now());
+ _string = "A";
+ _float = Float.valueOf(1);
+ _double = Double.valueOf(1);
+ _bigInteger = BigInteger.valueOf(1);
+ _hashMap = new HashMap();
+ _hashMap.put(1, "one");
+ _linkedHashMap = new LinkedHashMap();
+ _linkedHashMap.put(1, "one");
+ _char = Character.valueOf('a');
+ _boolean = Boolean.FALSE;
+ _byte = Byte.valueOf("1");
+ }
+
+ public boolean isNutNull() {
+ return _long != null &&
+ _integer != null &&
+ _date != null &&
+ _string != null &&
+ _float != null &&
+ _double != null &&
+ _bigInteger != null &&
+ _hashMap != null &&
+ _linkedHashMap != null &&
+ _char != null &&
+ _boolean != null &&
+ _byte != null;
+ }
Review comment:
We can be more paranoid here. My idea was, that if serialization ends without an error, it works. (this should be probably covered somewhere in GraalVM tests). But no problem with being more strict and checking the real values.
##########
File path: docs/modules/ROOT/pages/reference/extensions/core.adoc
##########
@@ -104,6 +104,27 @@ camel.beans.customBeanWithSetterInjection.counter = 123
As such, the class `PropertiesCustomBeanWithSetterInjection` needs to be link:https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection[registered for reflection], note that field access could be omitted in this case.
+==== Serialization in native mode
+
+If serialization support is requested via `quarkus.camel.native.reflection.serialization-enabled`, following classes are registered for serialization:
+
+* `java.lang.Boolean`
+* `java.lang.Byte`
+* `java.lang.Character`
+* `java.lang.Float`
+* `java.lang.Double`
+* `java.lang.Integer`
+* `java.lang.Long`
+* `java.lang.Number`
+* `java.lang.String`
+* `java.math.BigInteger`
+* `java.util.Date`
+* `java.util.HashMap`
+* `java.util.LinkedHashMap`
+* `org.apache.camel.support.DefaultExchangeHolder`
+
+Developers can register other classes for serialization via the `ReflectiveClassBuildItem`.
Review comment:
done
##########
File path: extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/spi/CamelSerializationBuildItem.java
##########
@@ -0,0 +1,25 @@
+/*
+ * 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.quarkus.core.deployment.spi;
+
+import io.quarkus.builder.item.MultiBuildItem;
+
+/**
+ * A build item that does not carry any data but it is used to signal that registration for serialization is requested.
Review comment:
done
##########
File path: docs/modules/ROOT/pages/reference/extensions/core.adoc
##########
@@ -224,6 +245,13 @@ A comma separated list of Ant-path style patterns to match class names that shou
| `string`
|
+|icon:lock[title=Fixed at build time] [[quarkus.camel.native.reflection.serialization-enabled]]`link:#quarkus.camel.native.reflection.serialization-enabled[quarkus.camel.native.reflection.serialization-enabled]`
+
+If `true`, basic classes are registered for serialization; otherwise Java serialization will not work in native mode.
Review comment:
done
##########
File path: integration-test-groups/foundation/core/src/main/java/org/apache/camel/quarkus/core/MySerializationObject.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.quarkus.core;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.time.Instant;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection(serialization = true)
+public class MySerializationObject implements Serializable {
+
+ private Long _long;
+ private Integer _integer;
+ private Date _date;
+ private String _string;
+ private Float _float;
+ private Double _double;
+ private BigInteger _bigInteger;
+ private HashMap _hashMap;
+ private LinkedHashMap _linkedHashMap;
+ private Character _char;
+ private Boolean _boolean;
+ private Byte _byte;
+
+ public void initValues() {
+ _long = 1l;
+ _integer = 1;
+ _date = Date.from(Instant.now());
+ _string = "A";
+ _float = Float.valueOf(1);
+ _double = Double.valueOf(1);
+ _bigInteger = BigInteger.valueOf(1);
+ _hashMap = new HashMap();
+ _hashMap.put(1, "one");
+ _linkedHashMap = new LinkedHashMap();
+ _linkedHashMap.put(1, "one");
+ _char = Character.valueOf('a');
+ _boolean = Boolean.FALSE;
+ _byte = Byte.valueOf("1");
+ }
+
+ public boolean isNutNull() {
+ return _long != null &&
+ _integer != null &&
+ _date != null &&
+ _string != null &&
+ _float != null &&
+ _double != null &&
+ _bigInteger != null &&
+ _hashMap != null &&
+ _linkedHashMap != null &&
+ _char != null &&
+ _boolean != null &&
+ _byte != null;
+ }
Review comment:
done
##########
File path: docs/modules/ROOT/pages/user-guide/native-mode.adoc
##########
@@ -111,3 +111,28 @@ in {@code application.properties} - e.g.
quarkus.index-dependency.commons-lang3.group-id = org.apache.commons
quarkus.index-dependency.commons-lang3.artifact-id = commons-lang3
----
+
+[[serialization]]
+== Registration for serialization
+
+If serialization support is requested via `quarkus.camel.native.reflection.serialization-enabled`, following classes are registered for serialization:
+
+* `java.lang.Boolean`
+* `java.lang.Byte`
+* `java.lang.Character`
+* `java.lang.Float`
+* `java.lang.Double`
+* `java.lang.Integer`
+* `java.lang.Long`
+* `java.lang.Number`
+* `java.lang.String`
+* `java.math.BigInteger`
+* `java.util.Date`
+* `java.util.HashMap`
+* `java.util.LinkedHashMap`
+* `org.apache.camel.support.DefaultExchangeHolder`
+
+Developers can configure classes for serialization via the serialization configuration file
Review comment:
Oh I understand one previous comment wrongly, I'll reword it with @RegisterForReflection(serialization = true)
##########
File path: docs/modules/ROOT/pages/user-guide/native-mode.adoc
##########
@@ -111,3 +111,28 @@ in {@code application.properties} - e.g.
quarkus.index-dependency.commons-lang3.group-id = org.apache.commons
quarkus.index-dependency.commons-lang3.artifact-id = commons-lang3
----
+
+[[serialization]]
+== Registration for serialization
+
+If serialization support is requested via `quarkus.camel.native.reflection.serialization-enabled`, following classes are registered for serialization:
+
+* `java.lang.Boolean`
+* `java.lang.Byte`
+* `java.lang.Character`
+* `java.lang.Float`
+* `java.lang.Double`
+* `java.lang.Integer`
+* `java.lang.Long`
+* `java.lang.Number`
+* `java.lang.String`
+* `java.math.BigInteger`
+* `java.util.Date`
+* `java.util.HashMap`
+* `java.util.LinkedHashMap`
+* `org.apache.camel.support.DefaultExchangeHolder`
+
+Developers can configure classes for serialization via the serialization configuration file
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] lburgazzoli edited a comment on pull request #2904: Use of serialization feature of Quakus (fro Sql and Minio)
Posted by GitBox <gi...@apache.org>.
lburgazzoli edited a comment on pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#issuecomment-880483809
oh this is really nice.
btw we should really add a task to revisit DefaultExchangeHolder as it has been designed when serialization was cool but now it should be better to use json/avro/protobof
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#discussion_r672281023
##########
File path: integration-test-groups/foundation/core/src/main/java/org/apache/camel/quarkus/core/MySerializationObject.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.quarkus.core;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.time.Instant;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection(serialization = true)
+public class MySerializationObject implements Serializable {
+
+ private Long _long;
+ private Integer _integer;
+ private Date _date;
+ private String _string;
+ private Float _float;
+ private Double _double;
+ private BigInteger _bigInteger;
+ private HashMap _hashMap;
+ private LinkedHashMap _linkedHashMap;
+ private Character _char;
+ private Boolean _boolean;
+ private Byte _byte;
+
+ public void initValues() {
+ _long = 1l;
+ _integer = 1;
+ _date = Date.from(Instant.now());
+ _string = "A";
+ _float = Float.valueOf(1);
+ _double = Double.valueOf(1);
+ _bigInteger = BigInteger.valueOf(1);
+ _hashMap = new HashMap();
+ _hashMap.put(1, "one");
+ _linkedHashMap = new LinkedHashMap();
+ _linkedHashMap.put(1, "one");
+ _char = Character.valueOf('a');
+ _boolean = Boolean.FALSE;
+ _byte = Byte.valueOf("1");
+ }
+
+ public boolean isNutNull() {
+ return _long != null &&
+ _integer != null &&
+ _date != null &&
+ _string != null &&
+ _float != null &&
+ _double != null &&
+ _bigInteger != null &&
+ _hashMap != null &&
+ _linkedHashMap != null &&
+ _char != null &&
+ _boolean != null &&
+ _byte != null;
+ }
Review comment:
We can be more paranoid here. My idea was, that if serialization ends without an error, it works. (this should be probably covered somewhere in GraalVM tests). But no problem with being more strict and check the real values.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#discussion_r672279530
##########
File path: docs/modules/ROOT/pages/reference/extensions/core.adoc
##########
@@ -224,6 +245,13 @@ A comma separated list of Ant-path style patterns to match class names that shou
| `string`
|
+|icon:lock[title=Fixed at build time] [[quarkus.camel.native.reflection.serialization-enabled]]`link:#quarkus.camel.native.reflection.serialization-enabled[quarkus.camel.native.reflection.serialization-enabled]`
+
+If `true`, basic classes are registered for serialization; otherwise Java serialization will not work in native mode.
Review comment:
Add listing classes - I thought that link to the list would be enough, but I can list them here as well.
Yes it is a overstatement, I'll change it.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on pull request #2904: Use of serialization feature of Quakus (fro Sql and Minio)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#issuecomment-880462369
I agree that basic stuff would be in quarkus - in the future. (I plan to create a PR there)
But some stuff like `org.apache.camel.support.DefaultExchangeHolder` would stay here.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] jamesnetherton commented on pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#issuecomment-882398105
@JiriOndrusek please rebase on `main` as Quarkus has been bumped to 2.1.0.CR1.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#discussion_r672260733
##########
File path: docs/modules/ROOT/pages/reference/extensions/core.adoc
##########
@@ -104,6 +104,27 @@ camel.beans.customBeanWithSetterInjection.counter = 123
As such, the class `PropertiesCustomBeanWithSetterInjection` needs to be link:https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection[registered for reflection], note that field access could be omitted in this case.
+==== Serialization in native mode
+
+If serialization support is requested via `quarkus.camel.native.reflection.serialization-enabled`, following classes are registered for serialization:
+
+* `java.lang.Boolean`
+* `java.lang.Byte`
+* `java.lang.Character`
+* `java.lang.Float`
+* `java.lang.Double`
+* `java.lang.Integer`
+* `java.lang.Long`
+* `java.lang.Number`
+* `java.lang.String`
+* `java.math.BigInteger`
+* `java.util.Date`
+* `java.util.HashMap`
+* `java.util.LinkedHashMap`
+* `org.apache.camel.support.DefaultExchangeHolder`
+
+Developers can register other classes for serialization via the `ReflectiveClassBuildItem`.
Review comment:
`ReflectiveClassBuildItem` is for extension developers and this is rather a part of user guide. I think we should better omit this sentence or mention some way how application devs can register additional classes for serialization. Don't we have a property for that? (Or I wonder whether `@RegisterForReflection` shouldn't be modify to allow that too?)
Wouldn't [native-mode.adoc](https://camel.apache.org/camel-quarkus/latest/user-guide/native-mode.html) be a better place for this whole section about Serialization in native mode?
##########
File path: docs/modules/ROOT/pages/reference/extensions/core.adoc
##########
@@ -224,6 +245,13 @@ A comma separated list of Ant-path style patterns to match class names that shou
| `string`
|
+|icon:lock[title=Fixed at build time] [[quarkus.camel.native.reflection.serialization-enabled]]`link:#quarkus.camel.native.reflection.serialization-enabled[quarkus.camel.native.reflection.serialization-enabled]`
+
+If `true`, basic classes are registered for serialization; otherwise Java serialization will not work in native mode.
Review comment:
It would be nice to list the classes here as well.
> otherwise Java serialization will not work in native mode.
Isn't that a bit of an overstatement? It would work, but only for the registered classes, no?
##########
File path: extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/spi/CamelSerializationBuildItem.java
##########
@@ -0,0 +1,25 @@
+/*
+ * 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.quarkus.core.deployment.spi;
+
+import io.quarkus.builder.item.MultiBuildItem;
+
+/**
+ * A build item that does not carry any data but it is used to signal that registration for serialization is requested.
Review comment:
```suggestion
* Signal that basic classes listed in {@code org.apache.camel.quarkus.core.deployment.CamelSerializationProcessor.baseSerializationClasses() should be registered for serialization.
```
##########
File path: integration-test-groups/foundation/core/src/main/java/org/apache/camel/quarkus/core/MySerializationObject.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.quarkus.core;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.time.Instant;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection(serialization = true)
+public class MySerializationObject implements Serializable {
+
+ private Long _long;
+ private Integer _integer;
+ private Date _date;
+ private String _string;
+ private Float _float;
+ private Double _double;
+ private BigInteger _bigInteger;
+ private HashMap _hashMap;
+ private LinkedHashMap _linkedHashMap;
+ private Character _char;
+ private Boolean _boolean;
+ private Byte _byte;
+
+ public void initValues() {
+ _long = 1l;
+ _integer = 1;
+ _date = Date.from(Instant.now());
+ _string = "A";
+ _float = Float.valueOf(1);
+ _double = Double.valueOf(1);
+ _bigInteger = BigInteger.valueOf(1);
+ _hashMap = new HashMap();
+ _hashMap.put(1, "one");
+ _linkedHashMap = new LinkedHashMap();
+ _linkedHashMap.put(1, "one");
+ _char = Character.valueOf('a');
+ _boolean = Boolean.FALSE;
+ _byte = Byte.valueOf("1");
+ }
+
+ public boolean isNutNull() {
+ return _long != null &&
+ _integer != null &&
+ _date != null &&
+ _string != null &&
+ _float != null &&
+ _double != null &&
+ _bigInteger != null &&
+ _hashMap != null &&
+ _linkedHashMap != null &&
+ _char != null &&
+ _boolean != null &&
+ _byte != null;
+ }
Review comment:
I'd vote for being more paranoid here - we should check whether the fields have the same values as set by `initValues()`
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#discussion_r672958613
##########
File path: docs/modules/ROOT/pages/user-guide/native-mode.adoc
##########
@@ -111,3 +111,28 @@ in {@code application.properties} - e.g.
quarkus.index-dependency.commons-lang3.group-id = org.apache.commons
quarkus.index-dependency.commons-lang3.artifact-id = commons-lang3
----
+
+[[serialization]]
+== Registration for serialization
+
+If serialization support is requested via `quarkus.camel.native.reflection.serialization-enabled`, following classes are registered for serialization:
+
+* `java.lang.Boolean`
+* `java.lang.Byte`
+* `java.lang.Character`
+* `java.lang.Float`
+* `java.lang.Double`
+* `java.lang.Integer`
+* `java.lang.Long`
+* `java.lang.Number`
+* `java.lang.String`
+* `java.math.BigInteger`
+* `java.util.Date`
+* `java.util.HashMap`
+* `java.util.LinkedHashMap`
+* `org.apache.camel.support.DefaultExchangeHolder`
+
+Developers can configure classes for serialization via the serialization configuration file
Review comment:
Oh I understand one previous comment wrongly, I'll reword it with @RegisterForReflection(serialization = true)
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #2904: Use of serialization feature of Quakus (includes Sql and Nitrite)
Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #2904:
URL: https://github.com/apache/camel-quarkus/pull/2904#discussion_r672260733
##########
File path: docs/modules/ROOT/pages/reference/extensions/core.adoc
##########
@@ -104,6 +104,27 @@ camel.beans.customBeanWithSetterInjection.counter = 123
As such, the class `PropertiesCustomBeanWithSetterInjection` needs to be link:https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection[registered for reflection], note that field access could be omitted in this case.
+==== Serialization in native mode
+
+If serialization support is requested via `quarkus.camel.native.reflection.serialization-enabled`, following classes are registered for serialization:
+
+* `java.lang.Boolean`
+* `java.lang.Byte`
+* `java.lang.Character`
+* `java.lang.Float`
+* `java.lang.Double`
+* `java.lang.Integer`
+* `java.lang.Long`
+* `java.lang.Number`
+* `java.lang.String`
+* `java.math.BigInteger`
+* `java.util.Date`
+* `java.util.HashMap`
+* `java.util.LinkedHashMap`
+* `org.apache.camel.support.DefaultExchangeHolder`
+
+Developers can register other classes for serialization via the `ReflectiveClassBuildItem`.
Review comment:
`ReflectiveClassBuildItem` is for extension developers and this is rather a part of user guide. I think we should better omit this sentence or mention some way how application devs can register additional classes for serialization. Don't we have a property for that? (Or I wonder whether `@RegisterForReflection` shouldn't be modify to allow that too?)
Wouldn't [native-mode.adoc](https://camel.apache.org/camel-quarkus/latest/user-guide/native-mode.html) be a better place for this whole section about Serialization in native mode?
##########
File path: docs/modules/ROOT/pages/reference/extensions/core.adoc
##########
@@ -224,6 +245,13 @@ A comma separated list of Ant-path style patterns to match class names that shou
| `string`
|
+|icon:lock[title=Fixed at build time] [[quarkus.camel.native.reflection.serialization-enabled]]`link:#quarkus.camel.native.reflection.serialization-enabled[quarkus.camel.native.reflection.serialization-enabled]`
+
+If `true`, basic classes are registered for serialization; otherwise Java serialization will not work in native mode.
Review comment:
It would be nice to list the classes here as well.
> otherwise Java serialization will not work in native mode.
Isn't that a bit of an overstatement? It would work, but only for the registered classes, no?
##########
File path: extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/spi/CamelSerializationBuildItem.java
##########
@@ -0,0 +1,25 @@
+/*
+ * 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.quarkus.core.deployment.spi;
+
+import io.quarkus.builder.item.MultiBuildItem;
+
+/**
+ * A build item that does not carry any data but it is used to signal that registration for serialization is requested.
Review comment:
```suggestion
* Signal that basic classes listed in {@code org.apache.camel.quarkus.core.deployment.CamelSerializationProcessor.baseSerializationClasses() should be registered for serialization.
```
##########
File path: integration-test-groups/foundation/core/src/main/java/org/apache/camel/quarkus/core/MySerializationObject.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.quarkus.core;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.time.Instant;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection(serialization = true)
+public class MySerializationObject implements Serializable {
+
+ private Long _long;
+ private Integer _integer;
+ private Date _date;
+ private String _string;
+ private Float _float;
+ private Double _double;
+ private BigInteger _bigInteger;
+ private HashMap _hashMap;
+ private LinkedHashMap _linkedHashMap;
+ private Character _char;
+ private Boolean _boolean;
+ private Byte _byte;
+
+ public void initValues() {
+ _long = 1l;
+ _integer = 1;
+ _date = Date.from(Instant.now());
+ _string = "A";
+ _float = Float.valueOf(1);
+ _double = Double.valueOf(1);
+ _bigInteger = BigInteger.valueOf(1);
+ _hashMap = new HashMap();
+ _hashMap.put(1, "one");
+ _linkedHashMap = new LinkedHashMap();
+ _linkedHashMap.put(1, "one");
+ _char = Character.valueOf('a');
+ _boolean = Boolean.FALSE;
+ _byte = Byte.valueOf("1");
+ }
+
+ public boolean isNutNull() {
+ return _long != null &&
+ _integer != null &&
+ _date != null &&
+ _string != null &&
+ _float != null &&
+ _double != null &&
+ _bigInteger != null &&
+ _hashMap != null &&
+ _linkedHashMap != null &&
+ _char != null &&
+ _boolean != null &&
+ _byte != null;
+ }
Review comment:
I'd vote for being more paranoid here - we should check whether the fields have the same values as set by `initValues()`
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org