Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] fix compilable issue in UnmodifiableCollectionsSerializer #55016

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

zhaohehuhu
Copy link
Contributor

@zhaohehuhu zhaohehuhu commented Jan 13, 2025

Why I'm doing:

as title

What I'm doing:

Copy UnmodifiableCollectionsSerializer.java to sr repository to fix compilable issue:
Unable to make field final java.util.Collection java.util.Collections$UnmodifiableCollection.c accessible: module java.base does not "opens java.util" to unnamed module @61322f9d
Refer to magro/kryo-serializers#131

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.4
    • 3.3
    • 3.2
    • 3.1
    • 3.0

@zhaohehuhu zhaohehuhu changed the title fix compilable issue in UnmodifiableCollectionsSerializer [Enhancement] fix compilable issue in UnmodifiableCollectionsSerializer Jan 13, 2025
throw new IllegalArgumentException("The type " + type + " is not supported.");
}
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most risky bug in this code is:
Casting of collections may lead to ClassCastException.

You can modify the code like this:

private Collection<?> getValues(Object coll) {
    if (coll instanceof Collection) {
        return new ArrayList<>((Collection<?>) coll);
    }
    throw new IllegalArgumentException("Provided object is not a collection.");
}

Additionally, it's essential to ensure that other parts of the code that use casting to specific collection types verify the type before casting. This adjustment prevents runtime exceptions when non-collection objects are passed inadvertently.

@zhaohehuhu
Copy link
Contributor Author

@gengjun-git plz help review the code.

// 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.starrocks.connector.iceberg;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you move it to this package com.starrocks.connector.share.iceberg ? and remove this package org.apache.iceberg class with the same name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

[FE Incremental Coverage Report]

pass : 0 / 0 (0%)

Signed-off-by: zhaohehuhu <[email protected]>
Signed-off-by: zhaohehuhu <[email protected]>
Signed-off-by: zhaohehuhu <[email protected]>
Signed-off-by: zhaohehuhu <[email protected]>
Signed-off-by: zhaohehuhu <[email protected]>
Signed-off-by: zhaohehuhu <[email protected]>
Signed-off-by: zhaohehuhu <[email protected]>
Signed-off-by: zhaohehuhu <[email protected]>
Signed-off-by: zhaohehuhu <[email protected]>
Copy link

[Java-Extensions Incremental Coverage Report]

coverage check fail. please retry. 😨

Please let me know when error again.

com.naver.nid.cover.parser.coverage.exception.ParseException: java.nio.file.NoSuchFileException: /home/runner/_work/starrocks/starrocks/java-extensions/result

Copy link

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants