Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resync BSQ blocks from resources #5900

Merged

Conversation

stejbac
Copy link
Contributor

@stejbac stejbac commented Dec 7, 2021

Prevent a "URI is not hierarchical" IllegalArgumentException from the expression, new File(dirUrl.toURI()), which occurs on Linux & Windows when listing the resource directory of BSQ blocks. Adapt a solution from StackOverflow (together with the earlier java.nio.file.FileSystem-based approach in #5898), which uses two separate code paths depending on the environment, into the new method FileUtil::listResourceDirectory.

The issue is caused by the resource URL taking one of the two forms:

  1. file:/Users/[USER]/Java/bisq/bisq/p2p/out/production/resources/BsqBlocks_BTC_MAINNET
  2. jar:file:...p2p.jar!/BsqBlocks_BTC_MAINNET

depending on whether the system is OSX or not.

--

I tested the PR on Linux & Windows, but have not been able to test the absence of a regression on OSX (though I don't expect this, as it should use a similar code path to the original).

Prevent a "URI is not hierarchical" IllegalArgumentException from the
expression, 'new File(dirUrl.toURI())', which occurs on Linux & Windows
when listing the resource directory of BSQ blocks. Adapt a solution from
StackOverflow which uses two separate code paths depending on the
environment, into the new method 'FileUtil::listResourceDirectory'.

The issue is caused by the resource URL taking one of the two forms:

  file:/Users/[USER]/Java/bisq/bisq/p2p/out/production/resources/BsqBlocks_BTC_MAINNET
  jar:file:...p2p.jar!/BsqBlocks_BTC_MAINNET

depending on whether the system is OSX or not.
Use 'java.nio.file.FileSystem' in place of 'java.util.jar.JarFile' to
list all the resources under a given classpath (on Windows & Linux), as
that is a bit neater and potentially more efficient than scanning the
entire ZIP directory structure.
@stejbac
Copy link
Contributor Author

stejbac commented Dec 7, 2021

I think the Codacy check is going to fail, due to a missed //NOPMD suppression on a line containing an unavoidable fully qualified name.

Amending and force-pushing the last commit to fix.

@stejbac stejbac force-pushed the fix-resync-blocks-from-resources branch from 706e3bd to 746061e Compare December 7, 2021 14:55
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK for Ubuntu Linux. 👍

@ripcurlx ripcurlx added this to the v1.8.0 milestone Dec 8, 2021
Copy link
Contributor

@ripcurlx ripcurlx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK from macOS Monterey. 👍

@ripcurlx ripcurlx merged commit 601163e into bisq-network:master Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants