Skip to content

Commit dd399de

Browse files
authored
reduce number of silenced compiler warnings (#810)
* reduce number of silenced compiler warnings * fix more warnings * fix more warnings * more warnings * fix more warnings * Update UriJavaAccessor.scala
1 parent 949571a commit dd399de

File tree

32 files changed

+43
-54
lines changed

32 files changed

+43
-54
lines changed

http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/PoolInterface.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ private[http] object PoolInterface {
225225
requestCallback.invokeWithFeedback((request, responsePromise)).failed.foreach { _ =>
226226
debug(
227227
"Request was sent to pool which was already closed, retrying through the master to create new pool instance")
228-
responsePromise.tryCompleteWith(master.dispatchRequest(poolId, request)(materializer))
228+
responsePromise.completeWith(master.dispatchRequest(poolId, request)(materializer))
229229
}
230230
override def shutdown()(implicit ec: ExecutionContext): Future[ShutdownReason] = {
231231
shutdownCallback.invoke(())

http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/PoolMasterActor.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ private[http] final class PoolMasterActor extends Actor with ActorLogging {
187187
// to this actor by the pool actor, they will be retried once the shutdown
188188
// has completed.
189189
val completed = pool.shutdown()(context.dispatcher)
190-
shutdownCompletedPromise.tryCompleteWith(
190+
shutdownCompletedPromise.completeWith(
191191
completed.map(_ => Done)(ExecutionContext.parasitic))
192192
statusById += poolId -> PoolInterfaceShuttingDown(shutdownCompletedPromise)
193193
case Some(PoolInterfaceShuttingDown(formerPromise)) =>
194194
// Pool is already shutting down, mirror the existing promise.
195-
shutdownCompletedPromise.tryCompleteWith(formerPromise.future)
195+
shutdownCompletedPromise.completeWith(formerPromise.future)
196196
case None =>
197197
// Pool does not exist, shutdown is not needed.
198198
shutdownCompletedPromise.trySuccess(Done)

http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2Multiplexer.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import org.apache.pekko
1717
import pekko.annotation.InternalApi
1818
import pekko.event.LoggingAdapter
1919
import pekko.http.impl.engine.http2.FrameEvent._
20-
import pekko.http.ccompat._
2120
import pekko.http.scaladsl.settings.Http2CommonSettings
2221
import pekko.macros.LogHelper
2322
import pekko.stream.stage.GraphStageLogic

http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/client/ResponseParsing.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private[http2] object ResponseParsing {
8989
case ("content-type", ct: String) =>
9090
if (contentType.isEmpty) {
9191
val contentTypeValue =
92-
ContentType.parse(ct).right.getOrElse(malformedRequest(s"Invalid content-type: '$ct'"))
92+
ContentType.parse(ct).getOrElse(malformedRequest(s"Invalid content-type: '$ct'"))
9393
rec(remainingHeaders.tail, status, OptionVal.Some(contentTypeValue), contentLength, seenRegularHeader,
9494
headers)
9595
} else malformedRequest("HTTP message must not contain more than one content-type header")

http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/hpack/Http2HeaderParsing.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private[pekko] object Http2HeaderParsing {
6060
}
6161
object ContentType extends HeaderParser[model.ContentType]("content-type") {
6262
override def parse(name: String, value: String, parserSettings: ParserSettings): model.ContentType =
63-
model.ContentType.parse(value).right.getOrElse(malformedRequest(s"Invalid content-type: '$value'"))
63+
model.ContentType.parse(value).getOrElse(malformedRequest(s"Invalid content-type: '$value'"))
6464
}
6565
object ContentLength extends Verbatim("content-length")
6666
object Cookie extends Verbatim("cookie")

http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpHeaderParser.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import pekko.http.scaladsl.settings.ParserSettings.{
2626
IllegalResponseHeaderNameProcessingMode,
2727
IllegalResponseHeaderValueProcessingMode
2828
}
29-
import pekko.http.ccompat._
3029
import pekko.http.impl.util._
3130
import pekko.http.impl.util.HttpConstants._
3231
import pekko.http.scaladsl.model.{ ErrorInfo, HttpHeader, MediaTypes, StatusCode, StatusCodes }

http-core/src/main/scala/org/apache/pekko/http/impl/util/EnhancedByteStringTraversableOnce.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ import pekko.util.ByteString
2222
*/
2323
@InternalApi
2424
private[http] class EnhancedByteStringTraversableOnce(val byteStrings: IterableOnce[ByteString]) extends AnyVal {
25-
def join: ByteString = byteStrings.foldLeft(ByteString.empty)(_ ++ _)
25+
def join: ByteString = byteStrings.iterator.foldLeft(ByteString.empty)(_ ++ _)
2626
}

http-core/src/main/scala/org/apache/pekko/http/impl/util/EnhancedString.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ private[http] class EnhancedString(val underlying: String) extends AnyVal {
5454
* leading and trailing delimiters are NOT ignored, i.e. they trigger the inclusion of an
5555
* empty leading or trailing empty string (respectively).
5656
*/
57-
def lazySplit(delimiter: Char): Stream[String] = {
58-
def split(start: Int = 0): Stream[String] = {
57+
def lazySplit(delimiter: Char): LazyList[String] = {
58+
def split(start: Int = 0): LazyList[String] = {
5959
val ix = underlying.indexOf(delimiter, start)
6060
if (ix < 0)
61-
Stream.cons(underlying.substring(start), Stream.Empty)
61+
LazyList.cons(underlying.substring(start), LazyList.empty[String])
6262
else
63-
Stream.cons(underlying.substring(start, ix), split(ix + 1))
63+
LazyList.cons(underlying.substring(start, ix), split(ix + 1))
6464
}
6565
split()
6666
}

http-core/src/main/scala/org/apache/pekko/http/impl/util/package.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ package object util {
5050
private[http] implicit def enhanceString_(s: String): EnhancedString = new EnhancedString(s)
5151
private[http] implicit def enhanceRegex(regex: Regex): EnhancedRegex = new EnhancedRegex(regex)
5252
private[http] implicit def enhanceByteStrings(
53-
byteStrings: TraversableOnce[ByteString]): EnhancedByteStringTraversableOnce =
53+
byteStrings: IterableOnce[ByteString]): EnhancedByteStringTraversableOnce =
5454
new EnhancedByteStringTraversableOnce(byteStrings)
5555
private[http] implicit def enhanceByteStringsMat[Mat](
5656
byteStrings: Source[ByteString, Mat]): EnhancedByteStringSource[Mat] =

http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ClientConnectionSettings.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ abstract class ClientConnectionSettings private[pekko] () { self: ClientConnecti
5555
*/
5656
final def getIdleTimeout: JDuration = JavaDurationConverter.toJava(idleTimeout)
5757
final def getSocketOptions: java.lang.Iterable[SocketOption] = socketOptions.asJava
58-
final def getUserAgentHeader: Optional[UserAgent] = (userAgentHeader: Option[UserAgent]).asJava
59-
final def getLogUnencryptedNetworkBytes: Optional[Int] = (logUnencryptedNetworkBytes: Option[Int]).asJava
58+
final def getUserAgentHeader: Optional[UserAgent] = (userAgentHeader: Option[UserAgent]).toJava
59+
final def getLogUnencryptedNetworkBytes: Optional[Int] = logUnencryptedNetworkBytes.toJava
6060

6161
/**
6262
* In 2.0.0, the return type of this method changed from `scala.concurrent.duration.Duration`
@@ -68,7 +68,7 @@ abstract class ClientConnectionSettings private[pekko] () { self: ClientConnecti
6868
final def getWebsocketRandomFactory: Supplier[Random] = new Supplier[Random] {
6969
override def get(): Random = websocketRandomFactory()
7070
}
71-
final def getLocalAddress: Optional[InetSocketAddress] = (localAddress: Option[InetSocketAddress]).asJava
71+
final def getLocalAddress: Optional[InetSocketAddress] = localAddress.toJava
7272

7373
/** The underlying transport used to connect to hosts. By default [[ClientTransport.TCP]] is used. */
7474
@ApiMayChange
@@ -102,9 +102,9 @@ abstract class ClientConnectionSettings private[pekko] () { self: ClientConnecti
102102
def withStreamCancellationDelay(newValue: java.time.Duration): ClientConnectionSettings
103103

104104
def withUserAgentHeader(newValue: Optional[UserAgent]): ClientConnectionSettings =
105-
self.copy(userAgentHeader = (newValue.asScala: Option[UserAgent]).map(_.asScala))
105+
self.copy(userAgentHeader = newValue.toScala.map(_.asScala))
106106
def withLogUnencryptedNetworkBytes(newValue: Optional[Int]): ClientConnectionSettings =
107-
self.copy(logUnencryptedNetworkBytes = newValue.asScala)
107+
self.copy(logUnencryptedNetworkBytes = newValue.toScala)
108108
def withWebsocketRandomFactory(newValue: java.util.function.Supplier[Random]): ClientConnectionSettings =
109109
self.copy(websocketSettings = websocketSettings.withRandomFactoryFactory(new Supplier[Random] {
110110
override def get(): Random = newValue.get()
@@ -116,7 +116,7 @@ abstract class ClientConnectionSettings private[pekko] () { self: ClientConnecti
116116
def withParserSettings(newValue: ParserSettings): ClientConnectionSettings =
117117
self.copy(parserSettings = newValue.asScala)
118118
def withLocalAddress(newValue: Optional[InetSocketAddress]): ClientConnectionSettings =
119-
self.copy(localAddress = newValue.asScala)
119+
self.copy(localAddress = newValue.toScala)
120120

121121
@ApiMayChange
122122
def withTransport(newValue: ClientTransport): ClientConnectionSettings = self.copy(transport = newValue.asScala)

0 commit comments

Comments
 (0)