Giter Site home page Giter Site logo

Enhancements about adblib HOT 10 CLOSED

tananaev avatar tananaev commented on August 24, 2024
Enhancements

from adblib.

Comments (10)

sampalmer avatar sampalmer commented on August 24, 2024 2

While waiting for read() (here), if isClosed is set true (here), read() would throw Exception (here) even if readQueue is still receiving stdout/stderr data (here) and we have one or more messages to be read() and displayed yet.
I hope this makes sense 😄

Ah, yeah that makes sense thanks! I've been running into this bug as well, but I hadn't realised why it was happening until I saw your fix!

I've just raised #11 to get this fixed in com.tananaev.adblib as well. I implemented the fix without changing the API to keep things simple for existing apps that use code like this:

while (!stream.isClosed()) {
    stream.read();
    // etc
}

from adblib.

tananaev avatar tananaev commented on August 24, 2024 1

Ideas sound good to me. Please make sure to make small PRs for each change, so it can be easily reviewed.

from adblib.

mirfatif avatar mirfatif commented on August 24, 2024 1

Sure!

Thanks.

Does that fix the issue where read() sometimes fails with an IOException instead of sending back the response text?

try (AdbStream stream = connection.open("shell:echo Hello world")) {
    byte[] response = stream.read();
    String responseText = new String(response, StandardCharsets.UTF_8);
    Assert.assertEquals("Hello world", responseText.trim());
}

While waiting for read() (here), if isClosed is set true (here), read() would throw Exception (here) even if readQueue is still receiving stdout/stderr data (here) and we have one or more messages to be read() and displayed yet.
I hope this makes sense 😄

So the following would definitely throw IOException on first read() without printing anything:

try (AdbStream stream = connection.open("shell:echo Hello world")) {
    SystemClock.sleep(1000);
    byte[] response = stream.read();
    System.out.println(new String(response, StandardCharsets.UTF_8).trim());
}

I've tried to fix this.

from adblib.

sampalmer avatar sampalmer commented on August 24, 2024

Will do!

Just regarding upgrading the protocol version, after further testing, it looks like the hanging connection issue wasn't related to protocol version after all, so I'll leave it at the original version.

from adblib.

sampalmer avatar sampalmer commented on August 24, 2024

Raised #7 for the thread safety issues

from adblib.

sampalmer avatar sampalmer commented on August 24, 2024

Raised #9 for timeout option

from adblib.

sampalmer avatar sampalmer commented on August 24, 2024

Raised #10 for auth exception

from adblib.

sampalmer avatar sampalmer commented on August 24, 2024

Closing this issue since it's been converted to pull requests

from adblib.

mirfatif avatar mirfatif commented on August 24, 2024

@tananaev @sampalmer may I merge recent PRs to com.cgutman.adblib (https://github.com/mirfatif/AdbLib)?

from adblib.

sampalmer avatar sampalmer commented on August 24, 2024

@tananaev @sampalmer may I merge recent PRs to com.cgutman.adblib (https://github.com/mirfatif/AdbLib)?

Sure!

I just looked at your fork and noticed you have a fix for AdbStream.read(): mirfatif/AdbLib@aaa08a4.

Does that fix the issue where read() sometimes fails with an IOException instead of sending back the response text?

try (AdbStream stream = connection.open("shell:echo Hello world")) {
    byte[] response = stream.read();
    String responseText = new String(response, StandardCharsets.UTF_8);
    Assert.assertEquals("Hello world", responseText.trim());
}

from adblib.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.