Hello,
Recently I found a bug in the JUCE JNI code in the method bool connect (WebInputStream::Listener* /*listener*/)
from juce_android_Network.cpp
:
The line that gets the java instance and create the GlobalReference is not deleting first the local reference:
bool connect (WebInputStream::Listener* /*listener*/)
//...
stream = GlobalRef (env->CallStaticObjectMethod (JuceAppActivity,
JuceAppActivity.createHTTPStream,
javaString (address).get(),
(jboolean) isPost,
postDataArray,
javaString (headers).get(),
(jint) timeOutMs,
statusCodeArray,
responseHeaderBuffer.get(),
(jint) numRedirectsToFollow,
javaString (httpRequest).get()));
When doing this the local reference returned by CallStaticObjectMethod
is not deleted and if there are more than 512 HTTP requests it will cause an exception. To fix this issue delete the local reference as follows:
jobject obj = env->CallStaticObjectMethod (JuceAppActivity,
JuceAppActivity.createHTTPStream,
javaString (address).get(),
(jboolean) isPost,
postDataArray,
javaString (headers).get(),
(jint) timeOutMs,
statusCodeArray,
responseHeaderBuffer.get(),
(jint) numRedirectsToFollow,
javaString (httpRequest).get());
stream = GlobalRef (obj);
env->DeleteLocalRef (obj);
Could you fix it for the next releases?
Thanks!