Copilot commented on code in PR #6768:
URL: https://github.com/apache/ignite-3/pull/6768#discussion_r2447923743
##########
migration-tools/modules/migration-tools-commons-tests/build.gradle:
##########
@@ -53,10 +58,30 @@ def unpackTask =
tasks.register('unpackClassesFromDependencies', Copy) {
"org/apache/ignite/cache/query/annotations/QuerySqlField\$Group.class"
}
+def createFullSampleClusterResources =
tasks.register('createFullSampleClusterResources') {
+ description = 'Generates the "compute-deployment-units.json" resource
file.'
Review Comment:
Task description references 'compute-deployment-units.json' but the actual
output file is 'fullsamplecluster'. Update the description to match the actual
file being generated.
```suggestion
description = 'Generates the "fullsamplecluster" resource file.'
```
##########
migration-tools/modules/migration-tools-persistence/src/main/java/org/apache/ignite/migrationtools/persistence/marshallers/ForeignObjectInputStream.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.ignite.migrationtools.persistence.marshallers;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamClass;
+import java.util.ArrayList;
+import java.util.List;
+import net.bytebuddy.ByteBuddy;
+import net.bytebuddy.description.modifier.Visibility;
+import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
+import net.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.Default;
+import net.bytebuddy.implementation.MethodCall;
+import net.bytebuddy.implementation.SuperMethodCall;
+
+/**
+ * {@link ObjectInputStream} implementation which prevents {@link
ClassNotFoundException}s from custom client libraries.
+ */
+public final class ForeignObjectInputStream extends ObjectInputStream {
+ private final List<Class<?>> dummyClasses;
+
+ private final ClassLoader publicClassloader;
+
+ /**
+ * Constructor.
+ *
+ * @param in Base input stream.
+ * @param classLoader classloader.
+ * @throws IOException may be thrown.
+ */
+ public ForeignObjectInputStream(InputStream in, ClassLoader classLoader)
throws IOException {
+ super(in);
+ this.enableResolveObject(true);
+ this.dummyClasses = new ArrayList<>();
+ this.publicClassloader = classLoader;
+ }
+
+ @Override
+ protected Class<?> resolveClass(ObjectStreamClass desc) throws
IOException, ClassNotFoundException {
+ Class<?> c;
+ try {
+ c = super.resolveClass(desc);
+ } catch (ClassNotFoundException ex) {
+ String className = desc.getName();
+ if (!className.startsWith("org.apache.ignite.")) {
+ throw ex;
+ }
+
+ // TODO: Test if it makes sense to throw a more positive exception
instead of just shielding the constructor.
+ c = new ByteBuddy()
+ .subclass(Object.class, Default.NO_CONSTRUCTORS)
+ .name(className)
+ .defineConstructor(Visibility.PRIVATE)
+
.intercept(SuperMethodCall.INSTANCE.andThen(MethodCall.run(() -> {
+ throw new RuntimeException("");
Review Comment:
Empty error message in RuntimeException. Provide a meaningful message
explaining why the dummy object cannot be instantiated.
```suggestion
throw new RuntimeException("Cannot instantiate dummy
object for class '" + className + "'. This class could not be found and a
placeholder was generated.");
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]