-
Notifications
You must be signed in to change notification settings - Fork 443
fix all compile warnings #1318
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
fix all compile warnings #1318
Changes from all commits
dd31050
4180a8a
9113c3d
89b24cc
fec2e2a
c1396db
50a418e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
install: | ||
- echo "Running a custom install command" | ||
- ./mvn.sh clean install -pl .,obp-commons && ./mvn.sh install -DskipTests -pl obp-api |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,26 +2,15 @@ package code.actorsystem | |
|
||
import code.api.APIFailure | ||
import net.liftweb.common._ | ||
import net.liftweb.json.JsonAST.JValue | ||
|
||
trait ObpActorHelper { | ||
|
||
def extractResult[T](in: T) = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. totally wrong use of generic and match case, cause warnings. |
||
def extractResult(in: Any) = { | ||
in match { | ||
case pf: ParamFailure[_] => | ||
pf.param match { | ||
case af: APIFailure => af | ||
case f: Failure => f | ||
case _ => pf | ||
} | ||
case af: APIFailure => af | ||
case f: Failure => f | ||
case l: List[_] => l.asInstanceOf[List[T]] | ||
case s: Set[_] => s.asInstanceOf[Set[T]] | ||
case Full(r) => r | ||
case j: JValue => j | ||
case t: T => t | ||
case _ => APIFailure(s"result extraction failed", 501) | ||
} | ||
case ParamFailure(_, _, _, param@ (_:APIFailure | _: Failure)) => param | ||
case pf: ParamFailure[_] => pf | ||
case Full(r) => r | ||
case _ => in | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import net.liftweb.common._ | |
import scala.concurrent.ExecutionContext.Implicits.global | ||
import scala.concurrent.duration._ | ||
import scala.concurrent.{Await, Future} | ||
import scala.reflect.ClassTag | ||
|
||
trait ObpActorInit extends MdcLoggable{ | ||
// Default is 3 seconds, which should be more than enough for slower systems | ||
|
@@ -20,38 +21,20 @@ trait ObpActorInit extends MdcLoggable{ | |
val TIMEOUT = (ACTOR_TIMEOUT seconds) | ||
implicit val timeout = Timeout(ACTOR_TIMEOUT * (1000 milliseconds)) | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. totally wrong use of generic and match case, and asInstanceOf. |
||
* This function extracts the payload from Future. | ||
* It is used for Old Style Endpoints at Kafka connector. | ||
* @param f The payload wrapped into Future | ||
* @tparam T The type of the payload | ||
* @return The payload | ||
*/ | ||
def extractFuture[T](f: Future[Any]): T = { | ||
val r = f.map { | ||
case s: Set[_] => s.asInstanceOf[Set[T]] | ||
case l: List[_] => l.asInstanceOf[List[T]] | ||
case t: T => t | ||
case _ => Empty ~> APIFailure(s"future extraction failed", 501) | ||
} | ||
Await.result(r, TIMEOUT).asInstanceOf[T] | ||
} | ||
|
||
/** | ||
* This function extracts the payload from Future and wraps it to Box. | ||
* It is used for Old Style Endpoints at Kafka connector. | ||
* @param f The payload wrapped into Future | ||
* @tparam T The type of the payload | ||
* @return The payload wrapped into Box | ||
*/ | ||
def extractFutureToBox[T](f: Future[Any]): Box[T] = { | ||
val r = f.map { | ||
case pf: ParamFailure[_] => Empty ~> pf | ||
case af: APIFailure => Empty ~> af | ||
def extractFutureToBox[T: ClassTag](f: Future[Any]): Box[T] = { | ||
val r: Future[Box[T]] = f.map { | ||
case f@ (_: ParamFailure[_] | _: APIFailure) => Empty ~> f | ||
case f: Failure => f | ||
case Empty => Empty | ||
case t: T => Full(t) | ||
case _ => Empty ~> APIFailure(s"future extraction to box failed", 501) | ||
case _ => Empty ~> APIFailure("future extraction to box failed", 501) | ||
} | ||
|
||
Await.result(r, TIMEOUT) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line do nothing, will cause a warning.