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

StringIndexOutOfBoundsException in `StringUtil.toLowerCaseAndDotted(String) - Fail to accept env variable named 00_PYTHON_2_7 #1167

Closed
99sono opened this issue May 13, 2024 · 5 comments

Comments

@99sono
Copy link

99sono commented May 13, 2024

The method io.smallrye.config.common.utils.StringUtil.toLowerCaseAndDotted(String) is causing a java.lang.StringIndexOutOfBoundsException when faced with an input parameter such as 00_PYTHON_2_7. This issue occurs during deployment of an application into WildFly 26.1.3 using the library smallrye-config-common-2.10.0.jar.

Steps to Reproduce:

  1. Create a unit test similar to the following:
package deleteMe;

import org.junit.Test;
import io.smallrye.config.common.utils.StringUtil;

public class SmallRyeStringUtilBugTest {

    @Test
    public void toLowerCaseAndDottedTest() {
        String temp01 = StringUtil.toLowerCaseAndDotted("Abc_EFD");

        // This environment variable is accepted:
        // String temp02 = StringUtil.toLowerCaseAndDotted("PYTHON_2_7");

        // However, this environment variable leads to an exception
        String temp02 = StringUtil.toLowerCaseAndDotted("00_PYTHON_2_7");
    }
}

Expected Behavior:
The method should handle input parameters correctly without causing exceptions.

Actual Behavior:
The method throws a StringIndexOutOfBoundsException when processing certain input strings.

Environment:

  • WildFly version: 26.1.3
  • Library: smallrye-config-common-2.10.0.jar

These were the maven dependencies on my pom.xml

        <dependency>
            <groupId>io.smallrye.config</groupId>
            <artifactId>smallrye-config-core</artifactId>
            <version>2.10.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.smallrye.config</groupId>
            <artifactId>smallrye-config-common</artifactId>
            <version>2.10.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.smallrye.config</groupId>
            <artifactId>smallrye-config</artifactId>
            <version>2.10.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.msc</groupId>
            <artifactId>jboss-msc</artifactId>
            <version>1.4.13.Final</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-microprofile-config-smallrye</artifactId>
            <version>26.1.3.Final</version>
            <scope>test</scope>
        </dependency>

Here is the stack trace from wildfly:

Thread [MSC service thread 1-8] (Suspended (exception java.lang.StringIndexOutOfBoundsException))	
	owns: java.util.concurrent.ConcurrentHashMap<K,V>  (id=640)	
	owns: org.jboss.as.server.deployment.DeploymentUnitPhaseService<T>  (id=641)	
	java.lang.AbstractStringBuilder.checkRangeSIOOBE(int, int, int) line: 1724	
	java.lang.StringBuilder(java.lang.AbstractStringBuilder).replace(int, int, java.lang.String) line: 946	
	java.lang.StringBuilder.replace(int, int, java.lang.String) line: 302	
	io.smallrye.config.common.utils.StringUtil.toLowerCaseAndDotted(java.lang.String) line: 118	
	io.smallrye.config.SmallRyeConfig$ConfigSources.generateDottedProperties(java.util.List<org.eclipse.microprofile.config.spi.ConfigSource>, io.smallrye.config.SmallRyeConfigSourceInterceptorContext) line: 733	
	io.smallrye.config.SmallRyeConfig$ConfigSources.<init>(io.smallrye.config.SmallRyeConfigBuilder) line: 559	
	io.smallrye.config.SmallRyeConfig.<init>(io.smallrye.config.SmallRyeConfigBuilder, io.smallrye.config.ConfigMappings) line: 68	
	org.wildfly.extension.microprofile.config.smallrye.MicroProfileConfigSubsystemAdd$1$1(io.smallrye.config.SmallRyeConfigBuilder).build() line: 449	
	io.smallrye.config.SmallRyeConfigFactory$Default.getConfigFor(io.smallrye.config.SmallRyeConfigProviderResolver, java.lang.ClassLoader) line: 59	
	org.wildfly.extension.microprofile.config.smallrye.MicroProfileConfigSubsystemAdd$1(io.smallrye.config.SmallRyeConfigProviderResolver).getConfig(java.lang.ClassLoader) line: 76	
	org.wildfly.extension.microprofile.config.smallrye.deployment.SubsystemDeploymentProcessor.deploy(org.jboss.as.server.deployment.DeploymentPhaseContext) line: 48	
	org.jboss.as.server.deployment.DeploymentUnitPhaseService<T>.start(org.jboss.msc.service.StartContext) line: 182	
	org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(org.jboss.msc.Service, org.jboss.msc.service.StartContext) line: 1739	
	org.jboss.msc.service.ServiceControllerImpl$StartTask.execute() line: 1701	
	org.jboss.msc.service.ServiceControllerImpl$StartTask(org.jboss.msc.service.ServiceControllerImpl$ControllerTask).run() line: 1559	
	org.jboss.threads.ContextClassLoaderSavingRunnable.run() line: 35	
	org.jboss.threads.EnhancedQueueExecutor.safeRun(java.lang.Runnable) line: 1990	
	org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(java.lang.Runnable) line: 1486	
	org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run() line: 1377	
	org.jboss.msc.service.ServiceContainerImpl$ServiceThread(java.lang.Thread).run() line: 829	

For the unit test exception we have:

java.lang.StringIndexOutOfBoundsException: start -1, end 0, length 2
	at java.base/java.lang.AbstractStringBuilder.checkRangeSIOOBE(AbstractStringBuilder.java:1724)
	at java.base/java.lang.AbstractStringBuilder.replace(AbstractStringBuilder.java:946)
	at java.base/java.lang.StringBuilder.replace(StringBuilder.java:302)
	at io.smallrye.config.common.utils.StringUtil.toLowerCaseAndDotted(StringUtil.java:118)
	at deleteMe.SmallRyeStringUtilBugTest.toLowerCaseAndDottedTest(SmallRyeStringUtilBugTest.java:17)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:93)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)


Thanks.

@radcortez
Copy link
Member

This was fixed in #1000, available in the latest Wildfly distribution.

I don't think there are going to be updates to WildFly 26.1.3. @xstefank what do you think?

@xstefank
Copy link
Member

We could probably backport it of there would be 26.1.4 but that's unlikely.

@radcortez
Copy link
Member

@99sono are you able to update Wildfly?

@99sono
Copy link
Author

99sono commented May 21, 2024

Ah, super. Thanks for that information. Then please feel free to close the defect. No, we cannot simply update WildFly whenever we want. We have specific update windows throughout the year to keep up with the latest and most stable runtime technology. However, it's good to know that this update is available.

In any case, this issue is more of a major annoyance and time-consuming for developers who are surprised by it and encounter difficulties deploying applications that others can deploy. Once you're aware of it, you can easily adapt your development environment to work around the problem. So, it's not critical at all once you have that knowledge.

@radcortez
Copy link
Member

Thank you! Sorry for the inconvenience.

@radcortez radcortez closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 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

No branches or pull requests

3 participants