Skip to content

Commit

Permalink
Scala 3 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KarelCemus committed May 5, 2024
1 parent da9537a commit 71d55aa
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,14 @@ private object RedisClientFactory {

@SuppressWarnings(Array("org.wartremover.warts.IsInstanceOf"))
override def afterChannelInitialized(channel: Channel): Unit = {
channel.pipeline.addLast(new IdleStateHandler(afterChannelTime, 0, 0)): Unit
channel.pipeline.addLast(new ChannelDuplexHandler() {
val _ = channel.pipeline.addLast(new IdleStateHandler(afterChannelTime, 0, 0))
val _ = channel.pipeline.addLast(new ChannelDuplexHandler() {
@throws[Exception]
override def userEventTriggered(ctx: ChannelHandlerContext, evt: Object): Unit =
if (evt.isInstanceOf[IdleStateEvent]) ctx.disconnect().sync(): Unit
}): Unit
if (evt.isInstanceOf[IdleStateEvent]) {
val _ = ctx.disconnect().sync()
}
})
}

},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ private[connector] class RedisConnectorImpl(
key,
value,
new SetArgs()
.when(expiration.isFinite, _.px(expiration.toMillis))
.when(ifNotExists, _.nx()),
.mapWhen(expiration.isFinite, _.px(expiration.toMillis))
.mapWhen(ifNotExists, _.nx()),
)
.toScala[Option[String]]
.map(_ contains "OK")
Expand Down Expand Up @@ -485,7 +485,7 @@ private[connector] object RedisConnectorImpl {

implicit private class ConditionalCall[T](private val thiz: T) extends AnyVal {

def when(condition: Boolean, f: T => T): T =
def mapWhen(condition: Boolean, f: T => T): T =
if (condition) f(thiz) // mutable side effect
else thiz

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import java.util.List;

public abstract class RedisCommandsMock implements RedisClusterAsyncCommands<String, String> {
public abstract class AbstractRedisCommandsMock implements RedisClusterAsyncCommands<String, String> {

@Override
final public RedisFuture<String> set(String key, String value, SetArgs setArgs) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package play.api.cache.redis.connector

abstract class RedisCommandsMock extends AbstractRedisCommandsMock
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class RedisConnectorFailureSpec extends AsyncUnitSpec with ImplicitFutureMateria

@SuppressWarnings(Array("org.wartremover.warts.Equals"))
override def equals(obj: Any): Boolean = obj match {
case that: Array[?] => that.length == expected.length && that.zip(expected).forall { case (a, b) => a == b }
case that: Array[?] => that.length == expected.length && expected.zip(that).forall { case (a, b) => a == b }
case _ => false
}

Expand Down

0 comments on commit 71d55aa

Please sign in to comment.