你应该将自己的Jackson版本导入到Flink项目中吗?

huangapple go评论61阅读模式
英文:

Should you import your own version of Jackson into a Flink Project?

问题

你应该将Jackson单独导入到Flink项目中,还是只使用flink-shaded版本的Jackson?为什么?

英文:

Should you import Jackson into a Flink project separately or just use the flink-shaded version of Jackson? And why?

答案1

得分: 2

使用带有较旧版本的Flink的阴影Jackson是一个不好的主意。

我们已经看到由以下类加载器泄漏引起的故障:

  • 用户使用其用户空间类解码JSON
  • Jackson在内部缓存这些类
  • 如果从阴影依赖项中使用,则此缓存位于Flink的类加载器中
  • 只要此类位于缓存中(可能需要相当长时间),用户代码类加载器就无法卸载
  • 作业重新启动或会话集群将加剧此问题

这在1.16.1和1.17.0中通过FLINK-29834进行了修复。

英文:

Using the shaded Jackson with older versions of Flink is a bad idea.

We've seen failures caused by the following class loader leak:

  • user decodes JSON with their user-space classes
  • Jackson caches these classes internally
  • this cache is in Flink's classloader if used from the shaded dependencies
  • user-code class loader cannot be unloaded as long as this class is in the cache (can be quite long)
  • Job restarts or session clusters will amplify this problem

This was fixed with FLINK-29834 in 1.16.1 and 1.17.0.

答案2

得分: 1

Here is the Chinese translation of the provided text:

EDIT: 请按照David Anderson的答案进行操作

如果您不关心库版本将由您(可能会变化)的运行时决定,那么您完全可以使用flink-shaded版本。

现在,该库已经被shade,所以如果您想控制版本,可以自行提供它。不会出现兼容性问题。

话虽如此,Jackson是一个相当稳定的库,我认为版本不是很重要。您可以只使用flink-shaded版本来进行更轻量级的jar捆绑。这还使您可以在将来遇到任何问题时自行选择。

对我来说,这不是一个问题。

英文:

EDIT: follow David Anderson's answer

> You can perfectly use the flink-shaded version is you don't care that
> the library version will be dictated by your (possibly-changing)
> runtime.
>
> Now, the lib is shaded so feel free to supply it yourself if you want
> control of the version. There will be no compatibility issues.
>
> This being said, Jackson is a fairly stable lib and I don't think
> versions matter a lot. You can just use the flink-shaded version for
> lighter jar bundling. This also leaves you free to pick your own if
> you encounter any problem in the future.
>
> This is a non-problem to me.

huangapple
  • 本文由 发表于 2023年5月10日 15:37:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76215989.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定