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

Potential bug in KubernetesConfigAdapter.toStringArray() while handling list input #1114

Open
tchangnb opened this issue Dec 19, 2022 · 1 comment

Comments

@tchangnb
Copy link

tchangnb commented Dec 19, 2022

Hi, I was trying to apply the following config to have Dekorate help to generate corresponding Kubernetes yaml,

dekorate:
  kubernetes:
    command: [
      "java",
      "-cp",
      "lib/*",
      "-Xms100m",
      "-Xmx4092m",
      "-XX:+AlwaysPreTouch",
      "-Xlog:gc*",
      "-XX:+UseG1GC",
      "-XX:MaxGCPauseMillis=2000",
      "-XX:InitiatingHeapOccupancyPercent=45",
      "-XX:+HeapDumpOnOutOfMemoryError",
      "-Dfile.encoding=UTF-8",
      "MyApplication"
    ]

Then, maven clean install reported the following error,

Caused by: java.lang.IndexOutOfBoundsException: Index 13 out of bounds for length 13
    at jdk.internal.util.Preconditions.outOfBounds (Preconditions.java:64)
    at jdk.internal.util.Preconditions.outOfBoundsCheckIndex (Preconditions.java:70)
    at jdk.internal.util.Preconditions.checkIndex (Preconditions.java:266)
    at java.util.Objects.checkIndex (Objects.java:359)
    at java.util.ArrayList.get (ArrayList.java:427)
    at io.dekorate.kubernetes.adapter.KubernetesConfigAdapter.toStringArray (KubernetesConfigAdapter.java:1510)
    at io.dekorate.kubernetes.adapter.KubernetesConfigAdapter.newBuilder (KubernetesConfigAdapter.java:1014)
    at io.dekorate.kubernetes.config.KubernetesConfigGenerator.addPropertyConfiguration (KubernetesConfigGenerator.java:46)
    at io.dekorate.Session.lambda$addPropertyConfiguration$1 (Session.java:167)
    at io.dekorate.Session.addConfiguration (Session.java:183)
    at io.dekorate.Session.addPropertyConfiguration (Session.java:167)
    at io.dekorate.spring.apt.SpringBootApplicationProcessor.process (SpringBootApplicationProcessor.java:76)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor (JavacProcessingEnvironment.java:1023)

Downloaded the source code of KubernetesConfigAdapter and it seemed the loop condition should be 'i < c.size()',

  public static String[] toStringArray(Object o) {
       .....ommitted.....
        else if (o instanceof List) {
          List c = (List) o;
          String[] result = new String[c.size()]; 
          for (int i=0; i <= c.size(); i++) {
            result[i] = String.valueOf(c.get(i));
          }
          return result;
        }
        return new String[0];
  }

dekorate version: 3.1.3

Please verify and let me know if my statements is not clear or any formatting guideline I should look at before posting. Thanks!

@iocanel
Copy link
Member

iocanel commented Dec 21, 2022

@tchangnb thanks for spotting this, this is generated code so I think that it needs to be addressed in sundrio.

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

2 participants