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

file name of the linkfile should be >= 8: String index out of range: 8 #10

Open
shenwei356 opened this issue Feb 19, 2022 · 1 comment

Comments

@shenwei356
Copy link

I found an interesting thing. When the file name of the linkfile is shorter than 8, it reports:

java -jar camiClient.jar -d 123.txt .
String index out of range: 8

After changing 123.txt to 1234.txt, no error was reported.

Java version

$ java -version
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

Another thing: it still reports errors after successfully downloading files.

java.util.concurrent.ExecutionException: java.lang.StringIndexOutOfBoundsException
        at java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1006)
        at cami.download.SwiftDownload.fileDownloadAll(SwiftDownload.java:79)
        at cami.download.SwiftDownload.downloadAll(SwiftDownload.java:26)
        at cami.CLI.runDownload(CLI.java:259)
        at cami.CLI.processCommandLine(CLI.java:142)
        at cami.CLI.main(CLI.java:401)
Caused by: java.lang.StringIndexOutOfBoundsException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:598)
        at java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1005)
        ... 5 more
Caused by: java.lang.StringIndexOutOfBoundsException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:598)
        at java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:677)
        at java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:735)
        at java.util.stream.ForEachOps$ForEachOp.evaluateParallel(ForEachOps.java:160)
        at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(ForEachOps.java:174)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233)
        at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
        at cami.download.SwiftDownload.lambda$fileDownloadAll$6(SwiftDownload.java:79)
        at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -71
        at java.lang.String.substring(String.java:1931)
        at cami.download.SwiftDownload.fileMatchesRegex(SwiftDownload.java:105)
        at cami.download.SwiftDownload.lambda$null$4(SwiftDownload.java:78)
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174)
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1380)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
        at java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:291)
        at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731)

@shenwei356
Copy link
Author

I guess it tries to detect whether the given value is a URL or file, cause the length of https:// is 8.

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

1 participant