.NullPointerException: Cannot invoke "java.io.InputStream.available()" because "this.val$is" is null
See original GitHub issueHi there, I’ve got the the following error using the following example in https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/kubectl/equivalents/PodExecEquivalent.java
2021-11-10 14:50:13,115 ERROR [io.fab.kub.cli.uti.InputStreamPumper] (pool-16-thread-1) Error while pumping stream.: java.lang.NullPointerException: Cannot invoke "java.io.InputStream.available()" because "this.val$is" is null
at io.fabric8.kubernetes.client.utils.InputStreamPumper$1.read(InputStreamPumper.java:53)
at io.fabric8.kubernetes.client.utils.InputStreamPumper.transferTo(InputStreamPumper.java:76)
at io.fabric8.kubernetes.client.utils.InputStreamPumper.lambda$pump$0(InputStreamPumper.java:89)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Here is my code:
class Foo{
val execLatch = CountDownLatch(1);
private val LOG: Logger = LoggerFactory.getLogger(Foo::class.java)
fun doSomething(): Unit {
val out = ByteArrayOutputStream()
val error = ByteArrayOutputStream()
val execWatch = kubernetesClient.pods()
.inNamespace(kubernetesClient.namespace)
.withName("MY-POD")
.inContainer("MY-CONTAINER")
.writingOutput(out)
.writingError(error)
.usingListener(MyPodExecListener())
.exec("du", "-s", "/home/abcd")
val latchTerminationStatus: Boolean = execLatch.await(5, TimeUnit.SECONDS)
if (!latchTerminationStatus) {
LOG.warn("Latch could not terminate within specified time")
}
LOG.info("Exec Output: {} ", out)
execWatch.close()
}
inner class MyPodExecListener : ExecListener {
override fun onOpen(response: okhttp3.Response?) {
println(response)
LOG.info("Shell was opened")
}
override fun onFailure(t: Throwable?, response: okhttp3.Response?) {
LOG.info("Some error encountered")
execLatch.countDown()
}
override fun onClose(i: Int, s: String) {
LOG.info("Shell Closing")
execLatch.countDown()
}
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
java - InputStream.available() generating Null pointer exception
I'm trying to build an HTTP server, I searched the net to solve this problem, but I did not find anything like that....
Read more >throw NPE when copy file from pod to local #3384 - GitHub
NullPointerException : Cannot invoke "java.io.InputStream.available()" because "this.val$is" is null at io.fabric8.kubernetes.client.utils.
Read more >How to use available method in java.io.InputStream - Tabnine
Reads all available bytes from InputStream as a byte array. * Uses <code>in.available()</code> to determine the size of input stream.
Read more >Example usage for java.io InputStream available - Java2s.com
Document. Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which...
Read more >java .lang.nullpointerexception Code Example - Code Grepper
NullPointerException : Cannot invoke "java.lang.CharSequence.length()" because "this.text" is null · Integrity check failed: java.security.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Should be a duplicate of #3384
It’s not related to the NPE. I’m not sure if there is a trace level for websocket traffic, if you can’t seem to get a log can you put breakpoints in ExecWebSocketListener.onMessage and cleanUpOnce to see if you are getting a message prior to the websocket being closed?