Whales have a large vocabulary, large brains, social structures, and extremely old ages. Many simpler animals communicate dangers, some even have particular words for humans. It's entirely reasonable that whales might have learned at some point that whaling ships were dangerous, maybe even assuming that all ships are dangerous, and then communicate that to other whales, even for a hundred years, which is less than the lifetime of some whales.