I'm uploading a patch that's similar to the original suggestion from ChenFolin.
When I tried the approach I suggested in my last comment, it didn't work. The reason is that SecondaryNameNode calls directly in to FSImage#loadFSEdits and depends on that method to call FSNamesystem.getFSNamesystem().dir.updateCountForINodeWithQuota() by side effect. It's a less impactful change to add the call in the if block for when the image is already current.
I've also added a test that simulates the error condition by running a cluster with separate directories for image and edits, forcing the fstime file for edits to contain 0, and then going through a series of restarts/checkpoints to make sure that it can still load the merged image. Before I applied the change in FSImage, this test would fail with EOFException on the last restart, similar to what is described in the bug report. After I applied the fix in FSImage, the test passed.