ppalaga commented on a change in pull request #1902:
URL: https://github.com/apache/camel-quarkus/pull/1902#discussion_r503701487



##########
File path: 
extensions/leveldb/runtime/src/main/java/org/apache/camel/quarkus/component/leveldb/OriginalByteBufferSupport.java
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.component.leveldb;
+
+import java.lang.reflect.Method;
+import java.nio.MappedByteBuffer;
+
+import com.google.common.base.Throwables;
+
+/**
+ * Unmap support was changed because of jdk9+ (see
+ * 
https://github.com/dain/leveldb/commit/39b6e0c38045281fba5f6532c52dc06905890cad)
+ * Current version of levelDB is using MethodHandle, which is not supported by 
GraalVM (see
+ * https://github.com/oracle/graal/issues/2761)
+ * Original way of using Method (instead of MethodHandle) is working in native 
mode,
+ * therefore this class contains code from levelDB class `ByteBufferSupport` 
from the time before mentioned change and
+ * is used via substitutions.

Review comment:
       This is good to merge, but please file a followup issue with the info 
above and paste the issue link here.

##########
File path: 
extensions/leveldb/runtime/src/main/java/org/apache/camel/quarkus/component/leveldb/ObjectCodecSubstitute.java
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.component.leveldb;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.oracle.svm.core.annotate.Inject;
+import com.oracle.svm.core.annotate.Substitute;
+import com.oracle.svm.core.annotate.TargetClass;
+import org.apache.camel.support.DefaultExchangeHolder;
+import org.fusesource.hawtbuf.codec.ObjectCodec;
+
+/**
+ * This os workaround for serialization of DefaultExchangeHolder.
+ * Once serialization is implemented in graalVM (see 
https://github.com/oracle/graal/issues/460), this substitution
+ * could
+ * be removed.
+ */
+@TargetClass(value = ObjectCodec.class)
+final class ObjectCodecSubstitute {
+
+    @Inject
+    private ObjectMapper objectMapper;

Review comment:
       What a neat trick! I must say I never heart of 
`com.oracle.svm.core.annotate.Inject` and I have issues to grasp how it works 
based on the little docs I was able to find. But if this works, it is a great 
strategy to workaround all Java serialization issues we encounter. 
@jamesnetherton you mentioned you were solving some serialization issue 
recently?
   
   This is good to merge for now, but to make it more robust, couldn't we 
replace `org.fusesource.hawtbuf:hawtbuf` with Jaskson in `camel-leveldb`? 
`hawtbuf` serialization seems to be just an implementation detail there so it 
could be relatively easy to do. Plz. file a followup if you like the idea. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to