Skip to content

Commit 1cd2416

Browse files
committed
Fix warning for Java 20 that the constructor for URL is deprecated. Now uses URI.
1 parent c36dd17 commit 1cd2416

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/main/scala/progscala3/concurrency/process/Process.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
package progscala3.concurrency.process
33

44
import scala.sys.process.*
5-
import java.net.URL
5+
import java.net.URI
66
import java.io.File
77

88
object DoProcess:
99

1010
// Build a process to open a URL, redirect the output to
1111
// "grep $filter", and append the output to file (not overwrite it).
1212
def findURL(url: String, filter: String) =
13-
URL(url) #> s"grep $filter" #>> File(s"$filter.txt")
13+
URI(url).toURL() #> s"grep $filter" #>> File(s"$filter.txt")
1414

1515
// Run ls -l on the file. If it exists, then count the lines.
1616
def countLines(fileName: String) =

src/script/scala/progscala3/basicoop/Exports.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// tag::traits[]
22
// src/script/scala/progscala3/basicoop/Exports.scala
33

4-
import java.net.URL
4+
import java.net.{URI, URL}
55

66
case class UserName(value: String): // <1>
77
assert(value.length > 0)
@@ -25,7 +25,7 @@ class DirectoryAuthenticate(location: URL) extends Authenticate:
2525
// tag::service1[]
2626
object ServiceWithoutExports:
2727
private val dirAuthenticate =
28-
DirectoryAuthenticate(URL("https://directory.wtf"))
28+
DirectoryAuthenticate(URI("https://directory.wtf").toURL())
2929

3030
def authenticate(username: UserName, password: Password): Boolean =
3131
dirAuthenticate(username, password)
@@ -35,7 +35,7 @@ object ServiceWithoutExports:
3535
// tag::service2[]
3636
object Service:
3737
private val dirAuthenticate =
38-
DirectoryAuthenticate(URL("https://directory.wtf"))
38+
DirectoryAuthenticate(URI("https://directory.wtf").toURL())
3939

4040
export dirAuthenticate.{isAuthenticated, apply as authenticate}
4141
// end::service2[]

src/script/scala/progscala3/basicoop/Exports2.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// This version of Exports.scala doesn't appear in the book, but it
44
// includes more examples of exporting parts of internal dependencies.
55

6-
import java.net.URL
6+
import java.net.{URI, URL}
77

88
case class UserName(value: String):
99
assert(value.length > 0)
@@ -41,7 +41,7 @@ class AsyncTokenizer extends AsyncWorker[String, Seq[String]]:
4141

4242
object ServiceWithoutExports:
4343
private val dirAuthenticate =
44-
DirectoryAuthenticate(URL("https://directory.wtf"))
44+
DirectoryAuthenticate(URI("https://directory.wtf").toURL())
4545
private val manager = ResourceManager(sys.env)
4646
private val tokenizer = AsyncTokenizer()
4747

@@ -55,7 +55,7 @@ object ServiceWithoutExports:
5555
// tag::service2[]
5656
object Service:
5757
private val dirAuthenticate =
58-
DirectoryAuthenticate(URL("https://directory.wtf"))
58+
DirectoryAuthenticate(URI("https://directory.wtf").toURL())
5959
private val manager = ResourceManager(sys.env)
6060
private val tokenizer = AsyncTokenizer()
6161

0 commit comments

Comments
 (0)