All Apps and Add-ons

InputStreamMonitor.updateBody throwing OutOfMemoryError for writing of InputStream in FileOutputStream

malpasdd
New Member

I'm writing file from network (using HttpURLConnection) to my device with code:

                BufferedInputStream bis = new BufferedInputStream(c.getInputStream());
                byte[] buffer = new byte[1024];
                int count = 0;
                long downloadedBytes = 0;
                while ((count = bis.read(buffer)) != -1) {
                    fos.write(buffer, 0, count);
                    downloadedBytes += count;
                }
                fos.close();
                bis.close();

When downloaded file is big (19MB), splunk throws RuntimeException:

java.lang.RuntimeException: An error occured while executing doInBackground()
                      at android.os.AsyncTask$3.done(AsyncTask.java:299)
                      at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
                      at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
                      at java.util.concurrent.FutureTask.run(FutureTask.java:239)
                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
                      at java.lang.Thread.run(Thread.java:841)
                   Caused by: java.lang.OutOfMemoryError
                      at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:94)
                      at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:145)
                      at java.lang.StringBuffer.append(StringBuffer.java:219)
                      at com.splunk.mint.network.io.InputStreamMonitor.updateBody(InputStreamMonitor.java:118)
                      at com.splunk.mint.network.io.InputStreamMonitor.read(InputStreamMonitor.java:78)
                      at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:142)
                      at java.io.BufferedInputStream.read(BufferedInputStream.java:309)
                      at java.io.InputStream.read(InputStream.java:163)

I tried Mint.addURLToBlackList - for domain name (domain.com) and for file (domain.com/file.ext), but doesn't work. I don't want to disable network monitoring. Is there any way, to download large file without this error?

Tags (2)
0 Karma

croyal_splunk
Splunk Employee
Splunk Employee

We recommend using MINT Gradle Plugin.

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...