Snapshot lookup by zone ignores the zone in its fallback (stray semicolon)

未關閉 適合新手
#14,770 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
78/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
java
領域
backend

研究方向

此錯誤位於 SnapshotDataFactoryImpl.getSnapshot(snapshotId, role, zoneId, retrieveAnySnapshotFromVolume) 中,透過 getSnapshotWithRoleAndZone 呼叫。從回退迴圈開始,其中 storeMgr.getStoreZoneId(...) 的 if 後面多出的 ; 使區域檢查失效;同時檢查兩個迴圈中的 long == Long 比較。完成標準是:回退只傳回請求區域中的副本,否則傳回 null,且該比較是 null 安全的。

由索引模型根據 Issue 內容生成。

描述

problem

SnapshotDataFactoryImpl.getSnapshot(snapshotId, role, zoneId, retrieveAnySnapshotFromVolume) (used by getSnapshotWithRoleAndZone) has a stray ; in its fallback loop:

if (zoneId == storeMgr.getStoreZoneId(ref.getDataStoreId(), ref.getRole())); {
    snapshotStore = ref;
    break;
}
Effect
fallback loop the if is a no-op, so the first copy of the snapshot from any zone is returned
both loops long == Long unboxes; if getStoreZoneId returns null (it does when the primary pool lookup throws) this is an NPE

Came in with #7873. Present on 4.22 and main.

versions

4.19 onward, 4.22, main.

The steps to reproduce the bug
  1. Have a snapshot whose only copy is in zone A.
  2. Call anything that looks it up with getSnapshotWithRoleAndZone(id, role, zoneB).
  3. The zone A copy is returned instead of null.
What to do about it?

Remove the ; and compare null-safely in both loops.

主要語言
Java
星號
3.1k
分支
1.4k
平均合併
6 天 18 小時
30 天內合併 PR
11

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

apache/cloudstack 的其他 Issue

查看 apache/cloudstack 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。