Upon returning from vacation, the chief abbot of the Laughing Monkey Clan found his temple in a state of panic and disarray. The financial system they had just modified was throwing NullPointerExceptions for all new customers. These users, disquieted in the extreme, were terminating their accounts after barely a day.
当笑猴部落的牧师度完休假回到了他所在的教堂,发现教堂陷入了一片恐慌和混乱当中。他们新修改的金融系统对所有用户都抛出了"NullPointerExceptions"的异常。出现这种问题的用户都极度不安,纷纷在仅仅一天之后就终结了在这个金融系统下的账户。
With some difficulty the abbot traced the problem to a method whose stated purpose was to return a List of the user’s transactions. If there were no transactions it returned null, rather than the empty list.
牧师费劲千辛万苦追踪到出现这个问题的原因在于系统中的一个类函数的设定上,这个类函数的作用是返回所有用户交易信息的列表。如果用户没有交易信息,那它就会返回一个Null,而不是一个空列表。
“Bring me the monk who wrote this method,” he told the temple guards. “And also the monk whose code invokes it.”
“把写这个类函数的僧侣带过来见我”,他告诉修道院的卫兵,“还有把写的代码中调用到这个类函数的僧侣也都带来。”
The first monk, who was the elder of the two, declared that the blame should be placed squarely at the feet of the second. “My Javadoc was clear in the extreme. It is not my fault that he did not check for nulls.” The second monk hung his head in shame and said nothing.
一共带来了两个僧侣,带来的第一个僧侣,比另外一个年长一些。他直接就说应该把责任放到调用这个类函数的僧侣头上。他说,“我在的Java文档里面已经写的很清楚了!他们调用的时候没有检查出来Null,不是我的错”。另一个僧侣听了这,羞愧的底下头什么都没说。
The abbot clapped his hands and two tall jade urns were set upon the floor, one before each monk. “Your punishments have been written on slips of paper within. Each day you are to remove the first slip your hand touches and obey its decree to the letter, until your urn is empty.”
牧师用手拍了拍放在地上的两个高高的玉瓶,并且一个人给了一个。“你们的惩罚都写在了玉瓶里面的纸片上”每天你们都要用手从玉瓶中拿出第一张纸片,然后按照纸片写的内容去执行,直到玉瓶中的纸片空了为止。
The younger monk was bade go first. His hand had not gone halfway into the urn when the rustling of paper was heard. Reading the slip, he bowed and left the room.
年轻一点的那个僧侣立马就按着这个要求去做了,他的手还没伸到玉瓶的一半,就听到了纸的沙沙声。阅读抽到的纸片后,他便鞠躬然后退出了房间。
The elder monk reached deep into his own urn until his fingers brushed the cold bottom. “There are no slips of paper in this urn,” said the monk, the slightest smile playing at the corner of his mouth.
年长一些的僧侣把手伸到了他的那个玉瓶的最深处甚至手都摸到了底,年长的僧侣说:“我的这个玉瓶里没有任何纸片啊”,说话时他嘴角挂着一丝微笑(他猜想,里面没有纸片,说明他不必接受惩罚了,为此他感到高兴)。
“Neither are there fish, nor ten mountains,” said the abbot.
牧师说:“(里面)既没有一条鱼,也没有十座山,(里面什么都没有)”。
The elder monk then cried out in pain. The urn fell over and shattered. A scorpion scuttled away across the tiles.
年长点的和尚忽然痛苦的尖叫一声,玉瓶也打翻摔到了地上,碎了。一直蝎子飞快的跑了出来,钻到瓦片下面消失了。
The abbot regarded the dying monk. “All nothings are not equal.”
牧师看着这个垂死的和尚,说:“空非无,无非空”。