-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use DummyCriteo if not initialized properly (#89)
* Use DummyCriteo if not initialized properly Problem: When an error happens during the initialization path, Criteo instance will be `null` and any future call to Criteo.getInstance() will throw a RuntimeException. Solution: DummyCriteo is assigned to Criteo singleton object, when any runtime exception is thrown during initialization. While the integration will not work, it will prevent the host application from crashing. Logging will allow us to investigate and correct the root cause with the publisher. * Guard against null application in CriteoInterstitial Problem: An `application` object is required for the SDK to operate properly. However, nothing prevents CriteoInterstitialActivity from being open even if `application` is null. Solution: CriteoInterstitial APIs must check wehther `application` is null or return immediately. This is a workaround to prevent apps from crashing in production but actions need to be taken in the future to: 1. Understand how `application` can be null for publishers. 2. Check whether we can reduce the scope of `application` within the SDk and use an Activity context when appropriate (in this case, the Activity context that is passed to CriteoInterstitial could be used). 3. Understand the implications of making the application object nullable.
- Loading branch information
Showing
7 changed files
with
133 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
publisher-sdk/src/test/java/com/criteo/publisher/CriteoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2020 Criteo | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.criteo.publisher; | ||
|
||
import static junit.framework.TestCase.assertEquals; | ||
|
||
import org.junit.Test; | ||
|
||
public class CriteoTest { | ||
|
||
@Test | ||
public void criteoInit_GivenNullApplication_DoesNotCrash() { | ||
try { | ||
new Criteo.Builder(null, "").init(); | ||
} catch (CriteoInitException e) { | ||
} | ||
|
||
assertEquals(DummyCriteo.class, Criteo.getInstance().getClass()); | ||
} | ||
|
||
} |