Skip to content

Commit 63a6926

Browse files
committed
config: Fix invalid EtcdConfig return value after JSON parse error
Follows-up 1f2daa9, 9b459d2, 110a21e. Bug: T156924 Change-Id: I79b7e11b32e5be46c8ebdfb5c937e38e46301c0e
1 parent a8dcb17 commit 63a6926

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

includes/config/EtcdConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ protected function fetchAllFromEtcdServer( $address ) {
243243

244244
$info = json_decode( $rbody, true );
245245
if ( $info === null || !isset( $info['node']['nodes'] ) ) {
246-
return [ null, $rcode, "Unexpected JSON response; missing 'nodes' list.", false ];
246+
return [ null, "Unexpected JSON response; missing 'nodes' list.", false ];
247247
}
248248

249249
$config = [];

tests/phpunit/includes/config/EtcdConfigTest.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -364,22 +364,18 @@ public function testLoadCacheExpiredNoLock() {
364364

365365
public static function provideFetchFromServer() {
366366
return [
367-
[
367+
'200 OK - Empty' => [
368368
'http' => [
369369
'code' => 200,
370370
'reason' => 'OK',
371-
'headers' => [
372-
'content-length' => 0,
373-
],
371+
'headers' => [ 'content-length' => 0 ],
374372
'body' => '',
375373
'error' => '(curl error: no status set)',
376374
],
377375
'expect' => [
378-
// FIXME: Returning 4 values instead of 3
379-
null,
380-
200,
376+
null, // data
381377
"Unexpected JSON response; missing 'nodes' list.",
382-
false
378+
false // retry
383379
],
384380
],
385381
];

0 commit comments

Comments
 (0)