Skip to content

Commit 3475ebf

Browse files
Steve BlockAndroid (Google) Code Review
authored andcommitted
Merge "Fix SslError.getPrimaryError() to return -1 if the set of errors is empty"
2 parents 11a6705 + 518f72c commit 3475ebf

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

core/java/android/net/http/SslError.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ public boolean hasError(int error) {
198198

199199
/**
200200
* Gets the most severe SSL error in this object's set of errors.
201-
* @return The most severe SSL error.
201+
* Returns -1 if the set is empty.
202+
* @return The most severe SSL error, or -1 if the set is empty.
202203
*/
203204
public int getPrimaryError() {
204205
if (mErrors != 0) {
@@ -208,9 +209,11 @@ public int getPrimaryError() {
208209
return error;
209210
}
210211
}
212+
// mErrors should never be set to an invalid value.
213+
assert false;
211214
}
212215

213-
return 0;
216+
return -1;
214217
}
215218

216219
/**

core/java/android/webkit/SslErrorHandlerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private SslErrorHandlerImpl(SslErrorHandler origin, LoadListener listener) {
159159

160160
if (DebugFlags.SSL_ERROR_HANDLER) {
161161
assert host != null;
162-
assert primary != 0;
162+
assert primary != -1;
163163
}
164164

165165
if (mSslPrefTable.containsKey(host) && primary <= mSslPrefTable.getInt(host)) {
@@ -260,7 +260,7 @@ public void cancel() {
260260

261261
if (DebugFlags.SSL_ERROR_HANDLER) {
262262
assert host != null;
263-
assert primary != 0;
263+
assert primary != -1;
264264
}
265265
boolean hasKey = mSslPrefTable.containsKey(host);
266266
if (!hasKey || primary > mSslPrefTable.getInt(host)) {

0 commit comments

Comments
 (0)