Skip to content

Commit

Permalink
Fix build warnings (#978)
Browse files Browse the repository at this point in the history
## Goal

Resolve miscellaneous compiler warnings , mostly about deprecated method usage. Made changes to proper methods, or added suppression annotation regarding the use of our own deprecated enum `LogType`. 

## Testing
Existing tests cover these changes
  • Loading branch information
bidetofevil committed Jun 21, 2024
2 parents 3d3566f + 1b06cd0 commit 7ae6904
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal class StartupServiceImpl(
private = true,
attributes = mapOf(
"ended-in-foreground" to endedInForeground.toString(),
"thread-name" to (threadName ?: "unknown"),
"thread-name" to threadName,
),
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("DEPRECATION")

package io.embrace.android.embracesdk.internal.api.delegate

import android.annotation.SuppressLint
Expand Down Expand Up @@ -52,7 +54,6 @@ internal class EmbraceInternalInterfaceImpl(
embraceImpl.logMessage(message, Severity.ERROR, properties)
}

@Suppress("DEPRECATION")
override fun logHandledException(
throwable: Throwable,
type: LogType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("DEPRECATION")

package io.embrace.android.embracesdk.internal.api.delegate

import android.annotation.SuppressLint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal class ViewTrackingApiDelegate(
override fun registerComposeActivityListener(app: Application) {
try {
val composeActivityListener = Class.forName("io.embrace.android.embracesdk.compose.ComposeActivityListener")
composeActivityListenerInstance = composeActivityListener.newInstance()
composeActivityListenerInstance = composeActivityListener.getDeclaredConstructor().newInstance()
app.registerActivityLifecycleCallbacks(composeActivityListenerInstance as Application.ActivityLifecycleCallbacks?)
} catch (e: Throwable) {
logger.logError("registerComposeActivityListener error", e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class EmbraceUrlStreamHandlerFactory implements URLStreamHandlerFactory {

static URLStreamHandler newUrlStreamHandler(String className) {
try {
return (URLStreamHandler) Class.forName(className).newInstance();
return (URLStreamHandler) Class.forName(className).getDeclaredConstructor().newInstance();
} catch (Exception e) {
// We catch Exception here instead of the specific exceptions that can be thrown due to a change in the way some
// of these exceptions are compiled on different OS versions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ internal class FakeLogRecordBuilder : LogRecordBuilder {
return this
}

override fun <T : Any?> setAttribute(key: AttributeKey<T>, value: T): LogRecordBuilder {
override fun <T : Any> setAttribute(key: AttributeKey<T>, value: T): LogRecordBuilder {
attributes[key.key.toString()] = value.toString()
return this
}
Expand Down

0 comments on commit 7ae6904

Please sign in to comment.