Filename creation error: IllegalArgumentException: Requested character count -1 is less than zero.
See original GitHub issueDescribe the bug
I’m seeing the following exception in CI when running 7.0 of Marathon. Not sure why CI is different than local.
Devices (please complete the following information):
- Device: emulator API 30
- OS: MacOS
Additional context It also retries indefinitely for some reason.
[main @coroutine#59] <D.0.0.1:5037:emulator-5578]> Unknown vendor exception caught. Considering this a recoverable error
Stacktrace:
java.lang.IllegalArgumentException: Requested character count -1 is less than zero.
at kotlin.text.StringsKt___StringsKt.take(_Strings.kt:565)
at com.malinskiy.marathon.io.FileManager.createFilename(FileManager.kt:84)
at com.malinskiy.marathon.io.FileManager.createFile(FileManager.kt:20)
at com.malinskiy.marathon.report.logs.LogWriter.saveLogs(LogWriter.kt:12)
at com.malinskiy.marathon.android.executor.listeners.LogCatListener.testEnded(LogCatListener.kt:42)
at com.malinskiy.marathon.android.executor.listeners.CompositeTestRunListener.testEnded(CompositeTestRunListener.kt:35)
at com.malinskiy.marathon.android.executor.listeners.CompositeTestRunListener$testEnded$1.invokeSuspend(CompositeTestRunListener.kt)
at (Coroutine boundary.()
at kotlinx.coroutines.TimeoutKt.withTimeoutOrNull(Timeout.kt:101)
at com.malinskiy.marathon.android.adam.AndroidDeviceTestRunner.execute(AndroidDeviceTestRunner.kt:64)
at com.malinskiy.marathon.android.adam.AdamAndroidDevice$execute$2$1.invokeSuspend(AdamAndroidDevice.kt:358)
at com.malinskiy.marathon.android.adam.AdamAndroidDevice$execute$2.invokeSuspend(AdamAndroidDevice.kt:356)
at com.malinskiy.marathon.android.adam.AdamAndroidDevice.execute(AdamAndroidDevice.kt:360)
at com.malinskiy.marathon.execution.device.DeviceActor$executeBatch$2.invokeSuspend(DeviceActor.kt:187)
Caused by: java.lang.IllegalArgumentException: Requested character count -1 is less than zero.
at kotlin.text.StringsKt___StringsKt.take(_Strings.kt:565)
at com.malinskiy.marathon.io.FileManager.createFilename(FileManager.kt:84)
at com.malinskiy.marathon.io.FileManager.createFile(FileManager.kt:20)
at com.malinskiy.marathon.report.logs.LogWriter.saveLogs(LogWriter.kt:12)
at com.malinskiy.marathon.android.executor.listeners.LogCatListener.testEnded(LogCatListener.kt:42)
at com.malinskiy.marathon.android.executor.listeners.CompositeTestRunListener.testEnded(CompositeTestRunListener.kt:35)
at com.malinskiy.marathon.android.executor.listeners.CompositeTestRunListener$testEnded$1.invokeSuspend(CompositeTestRunListener.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:33)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.UndispatchedCoroutine.afterResume(CoroutineContext.kt:142)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How can I be getting a "Count cannot be less than zero ...
From Microsoft Docs: String(Char c, Int32 count) Initializes the new instance to the value indicated by a specified Unicode character ...
Read more >Solving java.lang.IllegalArgumentException
java.lang.IllegalArgumentException is thrown in order to indicate that a method has been passed an illegal or inappropriate argument.
Read more >How to solve the error: Exception in thread "AWT-EventQueue ...
Adding an extra zero to the second name to make it "TFH00114H.TST" keeps the error, so I think my theory is correct. Renaming...
Read more >Built-in Exceptions — Python 3.11.1 documentation
This can be used to test an exception handler or to report an error condition “just like” the situation in which the interpreter...
Read more >SQL error messages and exceptions - Oracle Help Center
A connection could not be established because the server name (SRVNAM) has a length of zero or is larger than the maximum allowed...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

While this particular example is Window’s NTFS limitation, I can’t guarantee that there is no Linux filesystem that doesn’t have the same limitation. Currently, there is no API for JVM to capture the max filepath + max filename, so until such an API exists it is not a good idea to have
switch(os.version)in the code: the real limitation is on the filesystem implementation and there is no API to get the filesystem implementation as well.I’ve created a PR with a better error message for the issue at hand.
If you want to file another one with the filesystem limitations problem - feel free to do that.
another solution would be to create dynamic limits based on mac vs windows vs linux