Skip to content
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

S3: Minor cleanups #2740

Merged
merged 2 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object S3Attributes {

final class S3SettingsPath private (val path: String) extends Attribute
object S3SettingsPath {
val Default = S3SettingsPath(S3Settings.ConfigPath)
val Default: S3SettingsPath = S3SettingsPath(S3Settings.ConfigPath)

def apply(path: String) = new S3SettingsPath(path)
}
Expand Down
2 changes: 1 addition & 1 deletion s3/src/main/scala/akka/stream/alpakka/s3/S3Ext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class S3Ext private (sys: ExtendedActorSystem) extends Extension {
}

object S3Ext extends ExtensionId[S3Ext] with ExtensionIdProvider {
override def lookup = S3Ext
override def lookup: S3Ext.type = S3Ext
override def createExtension(system: ExtendedActorSystem) = new S3Ext(system)

/**
Expand Down
22 changes: 11 additions & 11 deletions s3/src/main/scala/akka/stream/alpakka/s3/S3Headers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class MetaHeaders private (val metaHeaders: Map[String, String]) {
metaHeaders = metaHeaders
)

override def toString =
override def toString: String =
"MetaHeaders(" +
s"metaHeaders=$metaHeaders," +
")"
Expand All @@ -45,7 +45,7 @@ object MetaHeaders {
def apply(metaHeaders: Map[String, String]) =
new MetaHeaders(metaHeaders)

def create(metaHeaders: java.util.Map[String, String]) =
def create(metaHeaders: java.util.Map[String, String]): MetaHeaders =
apply(metaHeaders.asScala.toMap)
}

Expand All @@ -70,13 +70,13 @@ final class S3Headers private (val cannedAcl: Option[CannedAcl] = None,
@InternalApi private[s3] def headersFor(request: S3Request) =
headers ++ serverSideEncryption.toIndexedSeq.flatMap(_.headersFor(request))

def withCannedAcl(cannedAcl: CannedAcl) = copy(cannedAcl = Some(cannedAcl))
def withMetaHeaders(metaHeaders: MetaHeaders) = copy(metaHeaders = Some(metaHeaders))
def withStorageClass(storageClass: StorageClass) = copy(storageClass = Some(storageClass))
def withCustomHeaders(customHeaders: Map[String, String]) = copy(customHeaders = customHeaders)
def withServerSideEncryption(serverSideEncryption: ServerSideEncryption) =
def withCannedAcl(cannedAcl: CannedAcl): S3Headers = copy(cannedAcl = Some(cannedAcl))
def withMetaHeaders(metaHeaders: MetaHeaders): S3Headers = copy(metaHeaders = Some(metaHeaders))
def withStorageClass(storageClass: StorageClass): S3Headers = copy(storageClass = Some(storageClass))
def withCustomHeaders(customHeaders: Map[String, String]): S3Headers = copy(customHeaders = customHeaders)
def withServerSideEncryption(serverSideEncryption: ServerSideEncryption): S3Headers =
copy(serverSideEncryption = Some(serverSideEncryption))
def withOptionalServerSideEncryption(serverSideEncryption: Option[ServerSideEncryption]) =
def withOptionalServerSideEncryption(serverSideEncryption: Option[ServerSideEncryption]): S3Headers =
copy(serverSideEncryption = serverSideEncryption)

private def copy(
Expand All @@ -93,7 +93,7 @@ final class S3Headers private (val cannedAcl: Option[CannedAcl] = None,
serverSideEncryption = serverSideEncryption
)

override def toString =
override def toString: String =
"S3Headers(" +
s"cannedAcl=$cannedAcl," +
s"metaHeaders=$metaHeaders," +
Expand Down Expand Up @@ -126,10 +126,10 @@ object S3Headers {
*/
val empty: S3Headers = new S3Headers()

def apply() = empty
def apply(): S3Headers = empty

/**
* Java Api
*/
def create() = empty
def create(): S3Headers = empty
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final class AES256 private[headers] () extends ServerSideEncryption {
case _ => Nil
}

override def toString =
override def toString: String =
"ServerSideEncryption.AES256(" +
")"

Expand Down Expand Up @@ -78,8 +78,8 @@ final class KMS private[headers] (val keyId: String, val context: Option[String]
case _ => Nil
}

def withKeyId(keyId: String) = copy(keyId = keyId)
def withContext(context: String) = copy(context = Some(context))
def withKeyId(keyId: String): KMS = copy(keyId = keyId)
def withContext(context: String): KMS = copy(context = Some(context))

private def copy(
keyId: String = keyId,
Expand All @@ -89,7 +89,7 @@ final class KMS private[headers] (val keyId: String, val context: Option[String]
context = context
)

override def toString =
override def toString: String =
"ServerSideEncryption.KMS(" +
s"keyId=$keyId," +
s"context=$context" +
Expand Down Expand Up @@ -143,8 +143,8 @@ final class CustomerKeys private[headers] (val key: String, val md5: Option[Stri
case _ => Nil
}

def withKey(key: String) = copy(key = key)
def withMd5(md5: String) = copy(md5 = Some(md5))
def withKey(key: String): CustomerKeys = copy(key = key)
def withMd5(md5: String): CustomerKeys = copy(md5 = Some(md5))

private def copy(
key: String = key,
Expand All @@ -154,7 +154,7 @@ final class CustomerKeys private[headers] (val key: String, val md5: Option[Stri
md5 = md5
)

override def toString =
override def toString: String =
"ServerSideEncryption.CustomerKeys(" +
s"key=$key," +
s"md5=$md5" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ import scala.concurrent.{ExecutionContext, Future}
val range = copyPartition.range
val source = copyPartition.sourceLocation.validate(conf)
val encodedKey = URLEncoder.encode(source.key, StandardCharsets.UTF_8.toString)
val sourceHeaderValuePrefix = s"/${source.bucket}/${encodedKey}"
val sourceHeaderValuePrefix = s"/${source.bucket}/$encodedKey"
val sourceHeaderValue = sourceVersionId
.map(versionId => s"$sourceHeaderValuePrefix?versionId=$versionId")
.getOrElse(sourceHeaderValuePrefix)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import akka.util.ByteString

package object auth {

private val Digits = "0123456789abcdef".toCharArray()
private val Digits = "0123456789abcdef".toCharArray

@InternalApi private[impl] def encodeHex(bytes: Array[Byte]): String = {
val length = bytes.length
val out = new Array[Char](length * 2)
for (i <- 0 to length - 1) {
for (i <- 0 until length) {
val b = bytes(i)
out(i * 2) = Digits((b >> 4) & 0xF)
out(i * 2 + 1) = Digits(b & 0xF)
Expand Down
10 changes: 5 additions & 5 deletions s3/src/main/scala/akka/stream/alpakka/s3/model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ final class MultipartUploadResult private (
versionId = versionId
)

override def toString =
override def toString: String =
"MultipartUploadResult(" +
s"location=$location," +
s"bucket=$bucket," +
Expand Down Expand Up @@ -412,10 +412,10 @@ final class FailedUpload private (

object FailedUpload {

def apply(reasons: Seq[Throwable]) = new FailedUpload(reasons)
def apply(reasons: Seq[Throwable]): FailedUpload = new FailedUpload(reasons)

/** Java API */
def create(reasons: Seq[Throwable]) = FailedUpload(reasons)
def create(reasons: Seq[Throwable]): FailedUpload = FailedUpload(reasons)
}

/**
Expand Down Expand Up @@ -476,7 +476,7 @@ final class ListBucketResultContents private (
storageClass = storageClass
)

override def toString =
override def toString: String =
"ListBucketResultContents(" +
s"bucketName=$bucketName," +
s"key=$key," +
Expand Down Expand Up @@ -564,7 +564,7 @@ final class ListBucketResultCommonPrefixes private (
prefix = prefix
)

override def toString =
override def toString: String =
"ListBucketResultCommonPrefixes(" +
s"bucketName=$bucketName," +
s"prefix=$prefix" +
Expand Down
24 changes: 12 additions & 12 deletions s3/src/main/scala/akka/stream/alpakka/s3/settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class Proxy private (
private def copy(host: String = host, port: Int = port, scheme: String = scheme): Proxy =
new Proxy(host = host, port = port, scheme = scheme)

override def toString =
override def toString: String =
"Proxy(" +
s"host=$host," +
s"port=$port," +
Expand Down Expand Up @@ -82,13 +82,13 @@ final class ForwardProxyCredentials private (val username: String, val password:
/** Java API */
def getPassword: String = password

def withUsername(username: String) = copy(username = username)
def withPassword(password: String) = copy(password = password)
def withUsername(username: String): ForwardProxyCredentials = copy(username = username)
def withPassword(password: String): ForwardProxyCredentials = copy(password = password)

private def copy(username: String = username, password: String = password) =
new ForwardProxyCredentials(username, password)

override def toString =
override def toString: String =
"ForwardProxyCredentials(" +
s"username=$username," +
s"password=******" +
Expand Down Expand Up @@ -137,18 +137,18 @@ final class ForwardProxy private (val scheme: String,
/** Java API */
def getCredentials: java.util.Optional[ForwardProxyCredentials] = credentials.asJava

def withScheme(value: String) = copy(scheme = value)
def withHost(host: String) = copy(host = host)
def withPort(port: Int) = copy(port = port)
def withCredentials(credentials: ForwardProxyCredentials) = copy(credentials = Option(credentials))
def withScheme(value: String): ForwardProxy = copy(scheme = value)
def withHost(host: String): ForwardProxy = copy(host = host)
def withPort(port: Int): ForwardProxy = copy(port = port)
def withCredentials(credentials: ForwardProxyCredentials): ForwardProxy = copy(credentials = Option(credentials))

private def copy(scheme: String = scheme,
host: String = host,
port: Int = port,
credentials: Option[ForwardProxyCredentials] = credentials) =
new ForwardProxy(scheme, host, port, credentials)

override def toString =
override def toString: String =
"ForwardProxy(" +
s"scheme=$scheme," +
s"host=$host," +
Expand All @@ -175,7 +175,7 @@ object ForwardProxy {
new ForwardProxy("https", host, port, credentials)

/** Java API */
def create(host: String, port: Int, credentials: Optional[ForwardProxyCredentials]) =
def create(host: String, port: Int, credentials: Optional[ForwardProxyCredentials]): ForwardProxy =
apply(host, port, credentials.asScala)

/** Use an HTTP proxy. */
Expand Down Expand Up @@ -316,7 +316,7 @@ final class MultipartUploadSettings private (val retrySettings: RetrySettings) {
/** Java API */
def getRetrySettings: RetrySettings = retrySettings

def withRetrySettings(value: RetrySettings) = MultipartUploadSettings(value)
def withRetrySettings(value: RetrySettings): MultipartUploadSettings = MultipartUploadSettings(value)

override def toString =
s"MultipartUploadSettings(retrySettings=$retrySettings)"
Expand Down Expand Up @@ -433,7 +433,7 @@ final class S3Settings private (
multipartUploadSettings
)

override def toString =
override def toString: String =
"S3Settings(" +
s"bufferType=$bufferType," +
s"credentialsProvider=$credentialsProvider," +
Expand Down