Skip to content

Commit abae305

Browse files
author
prsaminathan
committed
Update:
1. Addressed PR comments.
1 parent 3b25675 commit abae305

File tree

4 files changed

+49
-26
lines changed

4 files changed

+49
-26
lines changed

common4j/src/main/com/microsoft/identity/common/java/broker/BrokerPerformanceMetrics.kt

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// All rights reserved.
3+
//
4+
// This code is licensed under the MIT License.
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files(the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions :
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
// THE SOFTWARE.
123
package com.microsoft.identity.common.java.broker
224

325
import com.microsoft.identity.common.java.logging.Logger
@@ -53,22 +75,5 @@ class BrokerPerformanceMetrics(
5375

5476
companion object {
5577
private val TAG = BrokerPerformanceMetrics::class.java.simpleName
56-
57-
58-
/**
59-
* A safe default instance used when no real metrics are available.
60-
* Ensures non-null contract for Java callers.
61-
*
62-
* @param brokerRequestReceivedTimestamp Current time as placeholder.
63-
* @param brokerResponseGenerationTimestamp Current time as placeholder.
64-
*/
65-
@JvmField
66-
var EMPTY = run {
67-
val now = System.currentTimeMillis()
68-
BrokerPerformanceMetrics(
69-
brokerRequestReceivedTimestamp = now,
70-
brokerResponseGenerationTimestamp = now
71-
)
72-
}
7378
}
7479
}
Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// All rights reserved.
3+
//
4+
// This code is licensed under the MIT License.
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files(the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions :
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
// THE SOFTWARE.
123
package com.microsoft.identity.common.java.broker
224

325
interface IBrokerPerformanceMetricsProvider {
4-
var brokerPerformanceMetrics: BrokerPerformanceMetrics
26+
var brokerPerformanceMetrics: BrokerPerformanceMetrics?
527
}

common4j/src/main/com/microsoft/identity/common/java/exception/BaseException.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,11 @@ public String getUsername() {
221221
}
222222

223223
public void setBrokerPerformanceMetrics(final BrokerPerformanceMetrics brokerPerformanceMetrics) {
224-
this.mBrokerPerformanceMetrics = brokerPerformanceMetrics != null ?
225-
brokerPerformanceMetrics : BrokerPerformanceMetrics.EMPTY;
224+
this.mBrokerPerformanceMetrics = brokerPerformanceMetrics;
226225
}
227226

228227
public BrokerPerformanceMetrics getBrokerPerformanceMetrics() {
229-
return this.mBrokerPerformanceMetrics != null ?
230-
mBrokerPerformanceMetrics : BrokerPerformanceMetrics.EMPTY;
228+
return this.mBrokerPerformanceMetrics;
231229
}
232230

233231
public void setUsername(@Nullable final String username) {

common4j/src/main/com/microsoft/identity/common/java/result/AcquireTokenResult.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,11 @@ public void setTokenResult(TokenResult tokenResult) {
5858
}
5959

6060
public void setBrokerPerformanceMetrics(BrokerPerformanceMetrics brokerPerformanceMetrics) {
61-
this.mBrokerPerformanceMetrics = brokerPerformanceMetrics != null ?
62-
brokerPerformanceMetrics : BrokerPerformanceMetrics.EMPTY;
61+
this.mBrokerPerformanceMetrics = brokerPerformanceMetrics;
6362
}
6463

6564
public BrokerPerformanceMetrics getBrokerPerformanceMetrics() {
66-
return this.mBrokerPerformanceMetrics != null ?
67-
mBrokerPerformanceMetrics : BrokerPerformanceMetrics.EMPTY;
65+
return this.mBrokerPerformanceMetrics;
6866
}
6967

7068
// Suppressing rawtype warnings due to the generic type AuthorizationResult

0 commit comments

Comments
 (0)