2 Kings 22:20
Behold therefore, I will gather thee unto thy fathers, and thou shalt be gathered into thy grave in peace; and thine eyes shall not see all the evil which I will bring upon this place. And they brought the king word again. Behold therefore, I will gather thee unto thy fathers, and thou shalt be gathered into thy grave in peace; and thine eyes shall not see all the evil which I will bring upon this place. And they brought the king word again.
Because his heart was tender, Josiah humbled himself before God when he heard the warning that Jerusalem and its inhabitants would become a desolation and a curse. He tore his clothes and wept upon hearing God's warning. He promptly sought God for forgiveness and mercy. God heard him and promised to gather him to his fathers, so that his eyes would not see all the evil to be brought upon the place. That meant he would die and be buried in peace before seeing the coming calamity and judgment upon Judah and Jerusalem.
The promise was a personal mercy that spared Josiah from witnessing the calamity. It did not avert or cancel the nation's coming punishment. The judgment had become unavoidable because of the people's long rebellion, so Josiah had to leave future events with God.