简体   繁体   English

Apache Beam:IllegalStateException - 值仅在升级到 Beam 2.41.0 后的运行时可用

[英]Apache Beam: IllegalStateException - Value only available at runtime after upgrading to beam 2.41.0

I upgraded my Apache Beam version from 2.34.0 to 2.41.0 and getting the following error when trying to build the template.我将 Apache Beam 版本从 2.34.0 升级到 2.41.0,并在尝试构建模板时出现以下错误。

The error:错误:

Exception in thread "main" java.lang.IllegalStateException: Value only available at runtime, but accessed from a non-runtime context: RuntimeValueProvider{propertyName=spannerInstanceId, default=defaultinstanceid}
        at org.apache.beam.sdk.options.ValueProvider$RuntimeValueProvider.get(ValueProvider.java:254)
        at org.apache.beam.sdk.io.gcp.spanner.SpannerConfig.withInstanceId(SpannerConfig.java:165)
        at .... my code constructing SpannerConfig ...

My code looks like this:我的代码如下所示:

  private static SpannerConfig getValidatedSpannerConfig(MyCustomOptions options) {
    SpannerConfig spannerConfig =
        SpannerConfig.create()
            .withProjectId(options.getSpannerProjectId())
            .withInstanceId(options.getSpannerInstanceId())
            .withDatabaseId(options.getSpannerDatabaseId());
    spannerConfig.validate();
    return spannerConfig;
  }

Using Beam version <= 2.39.0 solving that issue.使用 Beam 版本 <= 2.39.0解决该问题。


Seems like the SpannerConfig withInstanceId method is causing this runtime read by calling get() ahead of time.似乎 SpannerConfig withInstanceId方法通过提前调用get()导致此运行时读取。
Is there a chance there is a bug in 2.40.0 and 2.41.0 versions of org.apache.beam:beam-sdks-java-io-google-cloud-platform ? org.apache.beam:beam-sdks-java-io-google-cloud-platform的 2.40.0 和 2.41.0 版本中是否有可能存在错误?

Decompiled version of 2.41.0 is: 2.41.0的反编译版本是:

  public SpannerConfig withInstanceId(ValueProvider<String> instanceId) {
    Preconditions.checkNotNull(instanceId);
    Preconditions.checkNotNull(instanceId.get()); // <<<<<< The problematic line
    return toBuilder().setInstanceId(instanceId).build();
  }

Decompiled version of 2.39.0 is: 2.39.0的反编译版本是:

  public SpannerConfig withInstanceId(ValueProvider<String> instanceId) {
    return toBuilder().setInstanceId(instanceId).build();
  }

I believe there is a bug there, introduced in 2.40.0, where it tries to read a value when it's not yet accessible.我相信那里有一个错误,在 2.40.0 中引入,当它还不能访问时,它会尝试读取一个值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM