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

Avoid java.net.URL #443

Merged
merged 5 commits into from
Jul 9, 2024
Merged

Conversation

jtjeferreira
Copy link
Contributor

I was using sbt without internet connection and noticed that update task taking a lot of time (around 30s). I did a thread dump with a SigQuit ( Ctrl + \) and noticed that the thread was blocked because java.net.URL#equals blocks:

"pool-514-thread-3" #918 prio=5 os_prio=31 cpu=292.62ms elapsed=128.20s tid=0x000000012d484a00 nid=0x1071b waiting for monitor entry  [0x0000000175550000]
   java.lang.Thread.State: BLOCKED (on object monitor)
	at java.net.InetAddress$NameServiceAddresses.get([email protected]/InetAddress.java:838)
	- waiting to lock <0x0000000737d5e758> (a java.net.InetAddress$NameServiceAddresses)
	at java.net.InetAddress.getAllByName0([email protected]/InetAddress.java:1533)
	at java.net.InetAddress.getAllByName([email protected]/InetAddress.java:1385)
	at java.net.InetAddress.getAllByName([email protected]/InetAddress.java:1306)
	at java.net.InetAddress.getByName([email protected]/InetAddress.java:1256)
	at java.net.URL.getHostAddress([email protected]/URL.java:831)
	- locked <0x00000007073fd680> (a java.net.URL)
	at java.net.URLStreamHandler.getHostAddress([email protected]/URLStreamHandler.java:447)
	at java.net.URLStreamHandler.hostsEqual([email protected]/URLStreamHandler.java:459)
	at java.net.URLStreamHandler.sameFile([email protected]/URLStreamHandler.java:431)
	at java.net.URLStreamHandler.equals([email protected]/URLStreamHandler.java:352)
	at java.net.URL.equals([email protected]/URL.java:980)
	at scala.runtime.BoxesRunTime.equals2(BoxesRunTime.java:137)
	at scala.runtime.BoxesRunTime.equals(BoxesRunTime.java:123)
	at scala.Some.equals(Option.scala:513)
	at sbt.librarymanagement.Artifact.equals(Artifact.scala:22)
	at scala.runtime.BoxesRunTime.equals2(BoxesRunTime.java:137)
	at scala.runtime.BoxesRunTime.equals(BoxesRunTime.java:123)
	at scala.Tuple2.equals(Tuple2.scala:24)
	at scala.runtime.BoxesRunTime.equals2(BoxesRunTime.java:137)
	at scala.runtime.BoxesRunTime.equals(BoxesRunTime.java:123)
	at scala.collection.IterableLike.sameElements(IterableLike.scala:304)
	at scala.collection.IterableLike.sameElements$(IterableLike.scala:294)
	at scala.collection.AbstractIterable.sameElements(Iterable.scala:56)
	at scala.collection.GenSeqLike.equals(GenSeqLike.scala:481)
	at scala.collection.GenSeqLike.equals$(GenSeqLike.scala:480)
	at scala.collection.AbstractSeq.equals(Seq.scala:45)
	at sbt.librarymanagement.ModuleReport.equals(ModuleReport.scala:34)
	at scala.runtime.BoxesRunTime.equals2(BoxesRunTime.java:137)
	at scala.runtime.BoxesRunTime.equals(BoxesRunTime.java:123)
	at scala.collection.IterableLike.sameElements(IterableLike.scala:304)
	at scala.collection.IterableLike.sameElements$(IterableLike.scala:294)
	at scala.collection.AbstractIterable.sameElements(Iterable.scala:56)
	at scala.collection.GenSeqLike.equals(GenSeqLike.scala:481)
	at scala.collection.GenSeqLike.equals$(GenSeqLike.scala:480)
	at scala.collection.AbstractSeq.equals(Seq.scala:45)
	at sbt.librarymanagement.ConfigurationReport.equals(ConfigurationReport.scala:21)

In this PR I replaced java.net.URL with java.net.URI but kept the field names(i.e I didn't rename url to uri, or browseUrl to browseUri)

@jtjeferreira jtjeferreira mentioned this pull request May 29, 2024
@jtjeferreira jtjeferreira force-pushed the avoid-java-net-URL-3 branch from e11d455 to 96640f7 Compare June 17, 2024 21:03
@jtjeferreira
Copy link
Contributor Author

@adpi2 can you review this PR? I rebase after your changes were merged

@jtjeferreira jtjeferreira force-pushed the avoid-java-net-URL-3 branch from 96640f7 to 861b8aa Compare June 17, 2024 21:18
Copy link
Member

@adpi2 adpi2 left a comment

Choose a reason for hiding this comment

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

LGTM!

@eed3si9n What do you think? Is it okay to break the source compat on Artifact.url between 1.x and 2.x? There are probably many plugins that depend on Artifact but maybe not so many on Artifact.url. Not even this one.

@adpi2 adpi2 requested a review from eed3si9n July 8, 2024 07:36
Copy link
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

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

LGTM

@jtjeferreira
Copy link
Contributor Author

LGTM

The test failures are normal?

@jtjeferreira
Copy link
Contributor Author

LGTM

The test failures are normal?

Thanks for rerunning the test @adpi2. CI / test (ubuntu-latest, 17, 1) is now green, but I think you have to rerun the other 2 ( CI / test (ubuntu-latest, 11, 1) and CI / test (ubuntu-latest, 8, 1) )

@adpi2
Copy link
Member

adpi2 commented Jul 9, 2024

Thanks for rerunning the test @adpi2. CI / test (ubuntu-latest, 17, 1) is now green, but I think you have to rerun the other 2 ( CI / test (ubuntu-latest, 11, 1) and CI / test (ubuntu-latest, 8, 1) )

I don't know why they appear as cancelled. But I think they were green before so let's just merge the PR.

@adpi2 adpi2 merged commit cc3ed47 into sbt:wip/sbt-2.x Jul 9, 2024
2 of 4 checks passed
@eed3si9n
Copy link
Member

eed3si9n commented Oct 4, 2024

I guess we haven't bumped LM in a while in sbt/sbt, so I just realized that when trying to use this, we get

[info] [info] welcome to sbt 2.0.0-alpha12-SNAPSHOT (Azul Systems, Inc. Java 1.8.0_402)
[info] [info] loading project definition from /private/var/folders/hg/2602nfrs2958vnshglyl3srw0000gn/T/sbt_3624414e/project
[info] [error] java.lang.ClassCastException: java.net.URL cannot be cast to java.net.URI
[info] [error] 	at sjsonnew.IsoString$$anon$1.to(IsoString.scala:26)
[info] [error] 	at sjsonnew.IsoFormats$$anon$2.write(IsoFormats.scala:31)
[info] [error] 	at sjsonnew.StandardFormats$OptionFormat.write(StandardFormats.scala:37)
[info] [error] 	at sjsonnew.StandardFormats$OptionFormat.addField(StandardFormats.scala:44)
[info] [error] 	at sjsonnew.StandardFormats$OptionFormat.addField(StandardFormats.scala:40)
[info] [error] 	at sjsonnew.Builder.addField(Builder.scala:43)
[info] [error] 	at sbt.librarymanagement.ArtifactFormats$$anon$1.write(ArtifactFormats.scala:36)
[info] [error] 	at sbt.librarymanagement.ArtifactFormats$$anon$1.write(ArtifactFormats.scala:29)

sbt/sbt#7720

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.

3 participants