rdblue commented on code in PR #4500:
URL: https://github.com/apache/iceberg/pull/4500#discussion_r848617460
##########
aliyun/src/main/java/org/apache/iceberg/aliyun/oss/OSSFileIO.java:
##########
@@ -111,7 +111,8 @@ public void initialize(Map<String, String> properties) {
this.metrics = ctor.newInstance("oss");
metrics.initialize(properties);
- } catch (NoSuchMethodException | ClassCastException e) {
+ } catch (NoClassDefFoundError | NoSuchMethodException | ClassCastException
e) {
+ this.metrics = MetricsContext.nullMetrics();
Review Comment:
No, you need to initialize a `MetricsContext` and then set `this.metrics` to
the _initialized_ context.
If it were me, I would use add a local variable. That can keep track of the
context and then you can update the instance field afterward:
```java
MetricsContext context = ctor.newInstance("scheme");
context.initialize(properties);
this.metrics = context;
```
The local variable helps you avoid modifying `metrics` until after
`initialize` is called, but you still use the initialized metrics context
instead of a completely new and uninitialized one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]