Skip to content

Commit

Permalink
Cleanup compiler warnings and flags (#216)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew de Detrich <mdedetrich@gmail.com>
  • Loading branch information
mdedetrich committed Aug 20, 2023
1 parent f6cc105 commit 2a52f71
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
7 changes: 4 additions & 3 deletions project/Settings.scala
Expand Up @@ -33,8 +33,7 @@ object Settings {
"-language:implicitConversions", // Allow definition of implicit functions called views
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
"-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access.
// "-Xfatal-warnings", // Fail the compilation if there are any warnings.
"-Xfuture", // Turn on future language features.
"-Xfatal-warnings", // Fail the compilation if there are any warnings.
"-Xlint:adapted-args", // Warn if an argument list is modified to match the receiver.
"-Xlint:delayedinit-select", // Selecting member of DelayedInit.
"-Xlint:doc-detached", // A Scaladoc comment appears to be detached from its element.
Expand Down Expand Up @@ -63,14 +62,16 @@ object Settings {
"-Ywarn-infer-any", // Warn when a type argument is inferred to be `Any`.
"-Xlint:nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'.
"-Xlint:nullary-unit", // Warn when nullary methods return Unit.
"-Xfuture", // Turn on future language features.
"-opt:l:inline",
"-opt-inline-from:<sources>"
)

private val scalacOptionsFor13 = Seq(
"-Xlint:_",
"-opt:l:inline",
"-opt-inline-from:<sources>"
"-opt-inline-from:<sources>",
"-Xlint:-byname-implicit" // See https://github.com/scala/bug/issues/12072#issuecomment-884514638
)

val sharedResolvers: Vector[MavenRepository] =
Expand Down
13 changes: 7 additions & 6 deletions src/main/scala/org/zalando/kanadi/api/Subscriptions.scala
Expand Up @@ -22,7 +22,6 @@ import org.mdedetrich.pekko.stream.support.CirceStreamSupport
import org.zalando.kanadi.models._
import org.zalando.kanadi.models

import scala.collection.JavaConverters._
import scala.concurrent.duration.FiniteDuration
import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success, Try}
Expand Down Expand Up @@ -1061,12 +1060,14 @@ case class Subscriptions(baseUri: URI, authTokenProvider: Option[AuthTokenProvid
}

private final val killSwitches =
new ConcurrentHashMap[(SubscriptionId, StreamId), UniqueKillSwitch]().asScala
new ConcurrentHashMap[(SubscriptionId, StreamId), UniqueKillSwitch]()

def addStreamToKillSwitch(subscriptionId: SubscriptionId,
streamId: StreamId,
uniqueKillSwitch: UniqueKillSwitch): Unit =
killSwitches((subscriptionId, streamId)) = uniqueKillSwitch
uniqueKillSwitch: UniqueKillSwitch): Unit = {
killSwitches.put((subscriptionId, streamId), uniqueKillSwitch)
()
}

private def getStreamUri(subscriptionId: SubscriptionId, streamConfig: Subscriptions.StreamConfig) =
baseUri_
Expand Down Expand Up @@ -1452,7 +1453,7 @@ case class Subscriptions(baseUri: URI, authTokenProvider: Option[AuthTokenProvid
modifySourceFunction: Option[
Source[SubscriptionEvent[T], UniqueKillSwitch] => Source[SubscriptionEvent[T], UniqueKillSwitch]])(implicit
decoder: Decoder[List[Event[T]]],
flowId: FlowId = randomFlowId(),
flowId: FlowId,
executionContext: ExecutionContext,
eventStreamSupervisionDecider: Subscriptions.EventStreamSupervisionDecider
): Future[StreamId] =
Expand Down Expand Up @@ -1602,7 +1603,7 @@ case class Subscriptions(baseUri: URI, authTokenProvider: Option[AuthTokenProvid
* reference. Note that cancelling the http connection will execute the [[eventsStreamed#connectionClosedCallback]]
*/
def closeHttpConnection(subscriptionId: SubscriptionId, streamId: StreamId): Boolean =
killSwitches.get((subscriptionId, streamId)) match {
Option(killSwitches.get((subscriptionId, streamId))) match {
case Some(killSwitch) =>
killSwitch.abort(CancelledByClient(subscriptionId, streamId))
true
Expand Down
Expand Up @@ -95,7 +95,7 @@ class BadJsonDecodingSpec
(result.owningApplication, result.eventTypes) mustEqual ((OwningApplication, Some(List(eventTypeName)))))
}

implicit val mySupervisionDecider =
implicit val mySupervisionDecider: Subscriptions.EventStreamSupervisionDecider =
Subscriptions.EventStreamSupervisionDecider { eventStreamContext: EventStreamContext =>
{
case parsingException: Subscriptions.EventJsonParsingException =>
Expand Down
10 changes: 4 additions & 6 deletions src/test/scala/org/zalando/kanadi/NoEmptySlotsSpec.scala
Expand Up @@ -84,9 +84,8 @@ class NoEmptySlotsSpec
subscriptionId <- currentSubscriptionId.future
stream <- subscriptionsClient.eventsStreamedManaged[SomeEvent](
subscriptionId,
EventCallback.successAlways { eventCallbackData =>
eventCallbackData.subscriptionEvent.events
.getOrElse(List.empty)
EventCallback.successAlways { _ =>
()
}
)
} yield stream
Expand All @@ -96,9 +95,8 @@ class NoEmptySlotsSpec
subscriptionId <- currentSubscriptionId.future
stream <- subscriptionsClient.eventsStreamedManaged[SomeEvent](
subscriptionId,
EventCallback.successAlways { eventCallbackData =>
eventCallbackData.subscriptionEvent.events
.getOrElse(List.empty)
EventCallback.successAlways { _ =>
()
}
)
} yield stream
Expand Down
Expand Up @@ -146,7 +146,7 @@ class EventPublishRetrySpec
}
}

implicit val flowId = FlowId(UUID.randomUUID().toString)
implicit val flowId: FlowId = FlowId(UUID.randomUUID().toString)

"Failed partial events are successfully retried" in { () =>
val future = for {
Expand Down

0 comments on commit 2a52f71

Please sign in to comment.