Skip to content

JDBCIO - handle empty driverjars argument#34514

Merged
Abacn merged 1 commit intoapache:masterfrom
stankiewicz:patch-2
Apr 2, 2025
Merged

JDBCIO - handle empty driverjars argument#34514
Abacn merged 1 commit intoapache:masterfrom
stankiewicz:patch-2

Conversation

@stankiewicz
Copy link
Copy Markdown
Contributor

handle empty string

YAML implementation passes default driver_jars: '' which is causing NPE in JDBCUtil.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@stankiewicz stankiewicz changed the title fix JDBCIO - handly empty driverjars argument Apr 2, 2025
@stankiewicz stankiewicz changed the title JDBCIO - handly empty driverjars argument JDBCIO - handle empty driverjars argument Apr 2, 2025
@Abacn
Copy link
Copy Markdown
Contributor

Abacn commented Apr 2, 2025

The original implementation was also resilient to empty string (driverJars="").

Splitter.on(',').trimResults().splitToList("");

I get [].

Could NPE happen somewhere else?

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2025

Assigning reviewers. If you would like to opt out of this review, comment assign to next reviewer:

R: @shunping for label java.
R: @damccorm for label build.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@stankiewicz
Copy link
Copy Markdown
Contributor Author

stankiewicz commented Apr 2, 2025

hey Yi,

you are right, NPE is further down:

Caused by: java.lang.NullPointerException: Cannot invoke "String.isEmpty()" because "segment" is null
	java.base/sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:271)
	java.base/java.nio.file.Path.of(Path.java:147)
	java.base/java.nio.file.Paths.get(Paths.java:69)
	org.apache.beam.sdk.io.jdbc.JdbcUtil.lambda$saveFilesLocally$0(JdbcUtil.java:125)
	java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)

when jarPath is empty string my guess is that
ResourceId sourceResourceId = FileSystems.matchNewResource(jarPath, false); returns "/" as CWD is root dir on worker and when this happens Paths.get("/tmp", sourceResourceId.getFilename()) throws npe because sourceResourceId.getFilename() is null.

@Abacn
Copy link
Copy Markdown
Contributor

Abacn commented Apr 2, 2025

Thanks for explanation, so the change makes the returned list from [""] to an empty list []. This LGTM

@Abacn Abacn merged commit ac6001d into apache:master Apr 2, 2025
16 checks passed
liferoad pushed a commit to liferoad/beam that referenced this pull request Apr 4, 2025
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