This repository was archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
This repository was archived by the owner on Sep 3, 2024. It is now read-only.
NullPointerException when I connect same address twice (double click the item) #24
Copy link
Copy link
Open
Labels
Description
Hello,
When I use andiodine, I got a null pointer exception when andiodine attempts to connect the same address twice if I click the item quickly.
I read the code snippets about Connect in IodineVpnService.java.
I found that
private final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
...
} else if (ACTION_CONTROL_CONNECT.equals(intent.getAction())) {
if (mThread != null) {
...
return;
}
...
//if OS schedules other threads at this point, it may lead some errors
mThread = new Thread(IodineVpnService.this, IodineVpnService.class.getName());
mThread.start();
}
}
};
I think those code may lead to synchronization errors if it calls method onReceive
twice. Therefore, andiodine should take extra synchronization (such as Synchronized {...}
) to fix it.
And the stack trace is:
E/AndroidRuntime( 7557): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Activity.sendBroadcast(android.content.Intent)' on a null object reference
E/AndroidRuntime( 7557): at org.xapek.andiodine.FragmentList.vpnServiceConnect2(FragmentList.java:203)
E/AndroidRuntime( 7557): at org.xapek.andiodine.FragmentList.access$600(FragmentList.java:30)
E/AndroidRuntime( 7557): at org.xapek.andiodine.FragmentList$3.onClick(FragmentList.java:177)
E/AndroidRuntime( 7557): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:162)
E/AndroidRuntime( 7557): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 7557): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime( 7557): at android.app.ActivityThread.main(ActivityThread.java:5254)
E/AndroidRuntime( 7557): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 7557): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime( 7557): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
E/AndroidRuntime( 7557): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)