appium/java-client

null pointer exception from remote DriverService class when outputstream or logfile are not passed.

vnkunta opened this issue · 15 comments

https://github.com/appium/java-client/blob/2fd8c0cadce1a97a8a73e6ede893499f3d80414b/src/main/java/io/appium/java_client/service/local/AppiumDriverLocalService.java#L92C32-L92C32

java.lang.NullPointerException
at java.base/java.io.FileOutputStream.(FileOutputStream.java:228)
at java.base/java.io.FileOutputStream.(FileOutputStream.java:187)
at org.openqa.selenium.remote.service.DriverService$Builder.getLogOutput(DriverService.java:448)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:495)
at io.appium.java_client.service.local.AppiumDriverLocalService.buildService(AppiumDriverLocalService.java:92)
at io.appium.java_client.service.local.AppiumDriverLocalService.buildDefaultService(AppiumDriverLocalService.java:88)

I got same error

Does Appium want process output sent to Console or Null by default?

(I'm assuming stderr?)

Appium does not pass anything by default. So it is DriverService that used to decide

So by default it is off, and only turned on if you specify a log location? How would you specify sending to console?

I created a PR above, but it would default to sending output to stderr. Should it be discarded by default?

Right now you can avoid this error by using any of these methods on an Appium service instance:

withLogOutput(System.out);
withLogOutput(System.err);
withLogOutput(ByteStreams.nullOutputStream());
withLogFile(new File(logLocation));

Ok, I just updated it to get discarded. This can be overridden using either of the methods above.

yes @titusfortner I had used the same i.e. withLogOutput(System.out);

I still find this issue, Can you give solution to resolve this?

Is it still an issue with Selenium 4.12.1?

Yes, I am still facing the same issue

@madhura-75 please provide the code, the exception, the new stack trace, and if you can turn on logging and provide the output that would be great: https://www.selenium.dev/documentation/webdriver/troubleshooting/logging/

You can also open a ticket in Selenium with this information, either way.

@titusfortner Is it fixed in selenium 4.12.1?

this is the issue I am facing

java.lang.NullPointerException

at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:226)

at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:184)

at org.openqa.selenium.remote.service.DriverService$Builder.getLogOutput(DriverService.java:448)

at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:495)

at io.appium.java_client.service.local.AppiumDriverLocalService.buildService(AppiumDriverLocalService.java:92)

at io.appium.java_client.service.local.AppiumDriverLocalService.buildDefaultService(AppiumDriverLocalService.java:88)

at eposautomation.Appium.EPOSBaseClass.startAppiumServer(EPOSBaseClass.java:48)

at eposautomation.Appium.HomeScreenTestCase.HomeScreenValidation(HomeScreenTestCase.java:43)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.base/java.lang.reflect.Method.invoke(Method.java:568)

at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)

at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:677)

at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:221)

at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)

at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:962)

at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:194)

at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)

at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)

at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

at org.testng.TestRunner.privateRun(TestRunner.java:806)

at org.testng.TestRunner.run(TestRunner.java:601)

at org.testng.SuiteRunner.runTest(SuiteRunner.java:433)

at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:427)

at org.testng.SuiteRunner.privateRun(SuiteRunner.java:387)

at org.testng.SuiteRunner.run(SuiteRunner.java:330)

at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)

at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)

at org.testng.TestNG.runSuitesSequentially(TestNG.java:1256)

at org.testng.TestNG.runSuitesLocally(TestNG.java:1176)

at org.testng.TestNG.runSuites(TestNG.java:1099)

at org.testng.TestNG.run(TestNG.java:1067)

at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)

at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)

at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

Is there any solution as of now? Till it gets merged in selenium?

We're hoping to get 4.13 out soon. You can try using the snapshot of latest, here - https://www.selenium.dev/downloads/#nightly