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

Fix NPE on Windows during certificate generation as File path separator differs to actual one #1197

Merged

Conversation

michalvavrik
Copy link
Member

@michalvavrik michalvavrik commented Jul 10, 2024

Summary

On Windows when running MssqlDatabaseIT we get:

java.lang.RuntimeException: Failed to generate certificate
	at io.quarkus.test.security.certificate.Certificate.of(Certificate.java:153)
	at io.quarkus.test.security.certificate.Certificate.of(Certificate.java:66)
	at io.quarkus.test.services.containers.SqlServerManagedResourceBuilder.build(SqlServerManagedResourceBuilder.java:41)
	at io.quarkus.test.bootstrap.BaseService.init(BaseService.java:295)
	at io.quarkus.test.bootstrap.QuarkusScenarioBootstrap.initService(QuarkusScenarioBootstrap.java:235)
	at io.quarkus.test.bootstrap.QuarkusScenarioBootstrap.initResourceFromField(QuarkusScenarioBootstrap.java:202)
	at io.quarkus.test.bootstrap.QuarkusScenarioBootstrap.lambda$beforeAll$1(QuarkusScenarioBootstrap.java:64)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at io.quarkus.test.bootstrap.QuarkusScenarioBootstrap.beforeAll(QuarkusScenarioBootstrap.java:64)
	at io.quarkus.test.bootstrap.QuarkusScenarioBootstrap.beforeAll(QuarkusScenarioBootstrap.java:50)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.StringIndexOutOfBoundsException: begin 0, end -1, length 24
	at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4606)
	at java.base/java.lang.String.substring(String.java:2709)
	at io.quarkus.test.security.certificate.Certificate.toSecretProperty(Certificate.java:305)
	at io.quarkus.test.security.certificate.Certificate.of(Certificate.java:128)
	... 10 more

That is because on Windows file separator is \\ but in fact Path#toString returns \, so here I decided to rely on Java API.

I have tested this both on Linux and Windows and this fixes the issue.

Please check the relevant options

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Dependency update
  • Refactoring
  • Breaking change (fix or feature that would cause existing functionality to change)
  • This change requires a documentation update
  • This change requires execution against OCP (use run tests phrase in comment)

Checklist:

  • Example scenarios has been updated / added
  • Methods and classes used in PR scenarios are meaningful
  • Commits are well encapsulated and follow the best practices

@michalvavrik michalvavrik added the triage/backport-1.4? Quarkus 3.8 stream label Jul 10, 2024
@michalvavrik
Copy link
Member Author

latest version JVM failure is unrelated known issue

2024-07-10T09:44:03.7612197Z 2024-07-10 09:44:03,679 ERROR [tc.qua.io/.41.0-k.7.0] (main) Could not start container: java.lang.IllegalStateException: Wait strategy failed. Container exited with code 1
2024-07-10T09:44:03.7614080Z 	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:533)
2024-07-10T09:44:03.7617462Z 	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:354)
2024-07-10T09:44:03.7619020Z 	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
2024-07-10T09:44:03.7620076Z 	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:344)
2024-07-10T09:44:03.7620981Z 	at io.strimzi.test.container.StrimziKafkaContainer.doStart(StrimziKafkaContainer.java:143)
2024-07-10T09:44:03.7621867Z 	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:330)
2024-07-10T09:44:03.7622903Z 	at io.quarkus.test.services.containers.DockerContainerManagedResource.doStart(DockerContainerManagedResource.java:122)
2024-07-10T09:44:03.7624051Z 	at io.quarkus.test.services.containers.DockerContainerManagedResource.start(DockerContainerManagedResource.java:72)

@fedinskiy fedinskiy merged commit 93d194b into quarkus-qe:main Jul 10, 2024
7 of 8 checks passed
@michalvavrik michalvavrik deleted the feature/fix-certs-gen-on-win branch July 10, 2024 10:38
@michalvavrik michalvavrik mentioned this pull request Jul 10, 2024
11 tasks
@michalvavrik michalvavrik removed the triage/backport-1.4? Quarkus 3.8 stream label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants