Copilot commented on code in PR #1541: URL: https://github.com/apache/fluss/pull/1541#discussion_r2276419922
########## fluss-lake/fluss-lake-iceberg/src/main/java/com/alibaba/fluss/lake/iceberg/conf/IcebergConfiguration.java: ########## @@ -0,0 +1,95 @@ +/* + * 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 com.alibaba.fluss.lake.iceberg.conf; + +import com.alibaba.fluss.config.Configuration; + +import org.apache.iceberg.common.DynClasses; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +/** + * Wraps the hadoop configuration used to configure {@link org.apache.iceberg.catalog.Catalog} if + * hadoop related classes is available. + * + * <p>It don't declare Hadoop configuration explicitly for some catalogs won't need hadoop + * configuration. For these catalogs, it won't throw class not found exception. It set the conf to + * null if no hadoop dependencies are found. It's fine to use null for the catalogs don't require + * Hadoop configuration. + * + * <p>For the catalogs require Hadoop configuration, hadoop related class not found exception will + * be thrown which guides users to add hadoop related classes. + */ +public class IcebergConfiguration implements Serializable { + + private static final Logger LOG = LoggerFactory.getLogger(IcebergConfiguration.class); + + private transient Object conf; + + private IcebergConfiguration(Configuration flussConfig) { + this.conf = loadHadoopConfig(flussConfig); + } + + public static IcebergConfiguration from(Configuration flussConfig) { + return new IcebergConfiguration(flussConfig); + } + + private void writeObject(ObjectOutputStream out) throws IOException { + out.defaultWriteObject(); + if (conf == null) { + out.writeBoolean(false); + } else { Review Comment: Missing `out.writeBoolean(true)` before calling `HadoopConfSerde.writeObject`. The writeObject method should write a boolean flag to indicate whether config is null or not, but currently only writes false for null case. ```suggestion } else { out.writeBoolean(true); ``` ########## fluss-lake/fluss-lake-iceberg/src/main/java/com/alibaba/fluss/lake/iceberg/conf/IcebergConfiguration.java: ########## @@ -0,0 +1,95 @@ +/* + * 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 com.alibaba.fluss.lake.iceberg.conf; + +import com.alibaba.fluss.config.Configuration; + +import org.apache.iceberg.common.DynClasses; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +/** + * Wraps the hadoop configuration used to configure {@link org.apache.iceberg.catalog.Catalog} if + * hadoop related classes is available. + * + * <p>It don't declare Hadoop configuration explicitly for some catalogs won't need hadoop + * configuration. For these catalogs, it won't throw class not found exception. It set the conf to + * null if no hadoop dependencies are found. It's fine to use null for the catalogs don't require + * Hadoop configuration. + * + * <p>For the catalogs require Hadoop configuration, hadoop related class not found exception will + * be thrown which guides users to add hadoop related classes. + */ +public class IcebergConfiguration implements Serializable { + + private static final Logger LOG = LoggerFactory.getLogger(IcebergConfiguration.class); + + private transient Object conf; + + private IcebergConfiguration(Configuration flussConfig) { + this.conf = loadHadoopConfig(flussConfig); + } + + public static IcebergConfiguration from(Configuration flussConfig) { + return new IcebergConfiguration(flussConfig); + } + + private void writeObject(ObjectOutputStream out) throws IOException { + out.defaultWriteObject(); + if (conf == null) { + out.writeBoolean(false); + } else { + HadoopConfSerde.writeObject(out, conf); + } + } + + private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException { + in.defaultReadObject(); + boolean configIsNull = in.readBoolean(); Review Comment: The `readBoolean()` call is not consistent with the `writeObject` method logic. In `writeObject`, when `conf == null`, `out.writeBoolean(false)` is called, but when `conf != null`, `HadoopConfSerde.writeObject` is called without writing a boolean. This will cause deserialization to fail when `conf` is not null. ########## fluss-lake/fluss-lake-iceberg/src/main/java/com/alibaba/fluss/lake/iceberg/conf/IcebergConfiguration.java: ########## @@ -0,0 +1,95 @@ +/* + * 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 com.alibaba.fluss.lake.iceberg.conf; + +import com.alibaba.fluss.config.Configuration; + +import org.apache.iceberg.common.DynClasses; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +/** + * Wraps the hadoop configuration used to configure {@link org.apache.iceberg.catalog.Catalog} if + * hadoop related classes is available. + * + * <p>It don't declare Hadoop configuration explicitly for some catalogs won't need hadoop + * configuration. For these catalogs, it won't throw class not found exception. It set the conf to + * null if no hadoop dependencies are found. It's fine to use null for the catalogs don't require + * Hadoop configuration. + * + * <p>For the catalogs require Hadoop configuration, hadoop related class not found exception will + * be thrown which guides users to add hadoop related classes. + */ +public class IcebergConfiguration implements Serializable { + + private static final Logger LOG = LoggerFactory.getLogger(IcebergConfiguration.class); + + private transient Object conf; + + private IcebergConfiguration(Configuration flussConfig) { + this.conf = loadHadoopConfig(flussConfig); + } + + public static IcebergConfiguration from(Configuration flussConfig) { + return new IcebergConfiguration(flussConfig); + } + + private void writeObject(ObjectOutputStream out) throws IOException { + out.defaultWriteObject(); + if (conf == null) { + out.writeBoolean(false); + } else { + HadoopConfSerde.writeObject(out, conf); + } + } + + private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException { + in.defaultReadObject(); + boolean configIsNull = in.readBoolean(); + if (configIsNull) { Review Comment: The boolean logic is inverted. Based on the writeObject method, `false` is written when `conf == null`, so the condition should be `if (!configIsNull)` to properly handle the null case. ```suggestion if (!configIsNull) { ``` -- 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]
