Skip to content

Commit 8412478

Browse files
authored
fix: Error handle null user attribute better and add use case to test file (#290)
1 parent 73872df commit 8412478

File tree

9 files changed

+11
-14
lines changed

9 files changed

+11
-14
lines changed

.github/workflows/daily.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ jobs:
256256

257257
semantic-release-dryrun:
258258
name: "Test Semantic Release - Dry Run"
259-
needs: [instrumented-tests, instrumented-orchestrator-tests, unit-tests, lint-checks, update-kits]
259+
needs: [instrumented-tests, instrumented-orchestrator-tests, unit-tests, lint-checks, kotlin-lint-checks, update-kits]
260260
runs-on: macos-latest
261261
env:
262262
GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}

android-core/src/androidTest/kotlin/com.mparticle/MPUserTest.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class MPUserTest : BaseCleanStartedEachTest() {
3232
setUserAttribute("fooDouble", 10.15)
3333
setUserAttribute("fooNegInt", -10L)
3434
setUserAttribute("fooNegLong", -1010L)
35+
this.userAttributes.put("fooNull", null)
3536
android_test_hack()
3637

3738
getUserAttributes(object : UserAttributeListener {
@@ -48,6 +49,7 @@ class MPUserTest : BaseCleanStartedEachTest() {
4849
assertEquals("10.15", userAttributes["fooDouble"])
4950
assertEquals("-10", userAttributes["fooNegInt"])
5051
assertEquals("-1010", userAttributes["fooNegLong"])
52+
assertEquals(null, userAttributes["fooNull"])
5153
}
5254
})
5355

@@ -64,6 +66,7 @@ class MPUserTest : BaseCleanStartedEachTest() {
6466
assertEquals(10.15, userAttributes["fooDouble"])
6567
assertEquals(-10L, userAttributes["fooNegInt"])
6668
assertEquals(-1010L, userAttributes["fooNegLong"])
69+
assertEquals(null, userAttributes["fooNull"])
6770
}
6871
})
6972
}

android-core/src/main/java/com/mparticle/internal/MessageManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ public void logNotification(ProviderCloudMessage cloudMessage, String appState)
646646

647647
@Override
648648
public void logNotification(int contentId, String payload, String appState, int newBehavior) {
649-
try{
649+
try {
650650
BaseMPMessage message = new BaseMPMessage.Builder(MessageType.PUSH_RECEIVED)
651651
.timestamp(System.currentTimeMillis())
652652
.name("gcm")
@@ -664,7 +664,7 @@ public void logNotification(int contentId, String payload, String appState, int
664664
message.put(MessageKey.APP_STATE, appState);
665665
mMessageHandler.sendMessage(mMessageHandler.obtainMessage(MessageHandler.STORE_MESSAGE, message));
666666

667-
}catch (JSONException e) {
667+
} catch (JSONException e) {
668668

669669
}
670670

android-core/src/main/java/com/mparticle/internal/database/services/MParticleDBManager.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

1212
import com.mparticle.MParticle;
1313
import com.mparticle.MParticleOptions;
14-
import com.mparticle.TypedUserAttributeListener;
15-
import com.mparticle.UserAttributeListener;
16-
import com.mparticle.UserAttributeListenerType;
1714
import com.mparticle.identity.UserAttributeListenerWrapper;
1815
import com.mparticle.internal.BatchId;
1916
import com.mparticle.internal.ConfigManager;
@@ -36,8 +33,6 @@
3633
import org.json.JSONException;
3734
import org.json.JSONObject;
3835

39-
import java.text.NumberFormat;
40-
import java.text.ParseException;
4136
import java.util.ArrayList;
4237
import java.util.HashMap;
4338
import java.util.List;

android-kit-base/src/main/java/com/mparticle/kits/FilteredMParticleUser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void onUserAttributesReceived(@NonNull Map<String, ?> userAttributes, @No
8686
if (entry.getValue() != null) {
8787
stringifiedAttributes.put(entry.getKey(), entry.getValue().toString());
8888
} else {
89-
stringifiedAttributes.put(entry.getKey(), "");
89+
stringifiedAttributes.put(entry.getKey(), null);
9090
}
9191
}
9292
((UserAttributeListener) listener).onUserAttributesReceived(

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.kotlin_version = '1.7.21'
2+
ext.kotlin_version = '1.7.22'
33
ext.gradle_version = '7.3.1'
44

55
repositories {

testutils/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ dependencies {
5454

5555
api 'androidx.annotation:annotation:1.5.0'
5656
api 'androidx.test.ext:junit:1.1.4'
57-
api 'androidx.test:rules:1.4.0'
57+
api 'androidx.test:rules:1.5.0'
5858

5959
androidTestCompileOnly project(':android-core')
6060

@@ -66,7 +66,7 @@ dependencies {
6666
}
6767
androidTestImplementation 'androidx.test:runner:1.3.0'
6868
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
69-
androidTestImplementation 'androidx.test:rules:1.3.0'
69+
androidTestImplementation 'androidx.test:rules:1.5.0'
7070
androidTestImplementation 'com.google.firebase:firebase-messaging:20.0.0'
7171

7272
androidTestUtil 'androidx.test:orchestrator:1.4.2'

testutils/src/main/java/com/mparticle/mock/AbstractMParticleUser.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import androidx.annotation.Nullable;
55

66
import com.mparticle.MParticle;
7-
import com.mparticle.UserAttributeListener;
87
import com.mparticle.UserAttributeListenerType;
98
import com.mparticle.consent.ConsentState;
109
import com.mparticle.identity.MParticleUser;

tooling/custom-lint-rules/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ buildscript {
1818
dependencies {
1919
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
2020
classpath "com.android.tools.build:gradle:$gradle_version"
21-
classpath 'com.guardsquare:proguard-gradle:7.2.2'
21+
classpath 'com.guardsquare:proguard-gradle:7.3.0'
2222
}
2323
}
2424

0 commit comments

Comments
 (0)