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!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...