Comments (5)
Looks like a bug: getStorageClass() of BucketInfo.LifecycleRule.SetStorageClassLifecycleAction class should be declared as public.
To workaround this issue you can create a class in the same package:
package com.google.cloud.storage;
public class StorageClassExtractor {
public static StorageClass extract(BucketInfo.LifecycleRule.LifecycleAction lifecycleAction) {
return ((BucketInfo.LifecycleRule.SetStorageClassLifecycleAction)lifecycleAction).getStorageClass();
}
}
Then you can use your helper class to access this method:
package storage;
import com.google.cloud.storage.BucketInfo;
import com.google.cloud.storage.StorageClass;
import com.google.cloud.storage.StorageClassExtractor;
public class LifecycleActionTest {
public static void main(String... args) {
BucketInfo.LifecycleRule.LifecycleAction lifecycleAction =
BucketInfo.LifecycleRule.LifecycleAction.newSetStorageClassAction(StorageClass.MULTI_REGIONAL);
if (lifecycleAction.getActionType().equals(BucketInfo.LifecycleRule.SetStorageClassLifecycleAction.TYPE)) {
System.out.println(StorageClassExtractor.extract(lifecycleAction));
}
}
}
from java-storage.
To workaround this issue you can create a class in the same package:
I don't get it.. Could you please elaborate.
when can I expect the bug fix on google-cloud-storage-1.7.8.0.jar?
from java-storage.
To workaround this issue you can create a class in the same package:
I don't get it.. Could you please elaborate.
You can create StorageClassExtractor.java file in your project, it will have an access to the method your need. In your app you can use StorageClassExtractor to get StorageClass.
when can I expect the bug fix on google-cloud-storage-1.7.8.0.jar?
I will work on it, but I can't promise any date.
from java-storage.
workaround:
public StorageClass extractStorageClass(LifecycleAction lifecycleAction) {
try {
Method method = SetStorageClassLifecycleAction.class.getDeclaredMethod("getStorageClass");
method.setAccessible(true);
return (StorageClass)method.invoke(lifecycleAction);
} catch (ReflectiveOperationException e) {
throw new RuntimeException("Exception while reading storage class from lifecycle rules", e);
}
}
from java-storage.
Yes, this is another workaround. But it will not work if you have security restrictions preventing you from invoking private methods. If you don't have such restrictions this will work fine.
from java-storage.
Related Issues (20)
- Cloud storage v2 API, add support for batch operations HOT 2
- Retrying idempotent requests that return 503 backendError HOT 1
- com.google.cloud.storage.StorageException: java.lang.IllegalStateException: Connection pool shut down when trying to check if bucket exists HOT 5
- CVE-2023-33953 through io.grpc.* (1.56.1) HOT 3
- com.example.storage.QuickstartSampleIT: testQuickstartGrpc failed HOT 1
- com.example.storage.QuickstartSampleIT: testQuickstartGrpcDp failed HOT 1
- Google Cloud Storage library using deprecated javax package HOT 4
- Async / streaming support
- com.example.storage.bucket.PrintPubSubNotificationTest: testPrintBucketPubSubNotification failed HOT 2
- Warning: a recent release failed HOT 2
- Add support for Autoclass v2.1 HOT 1
- grpc compatibility with storage 2.27.x HOT 3
- Google Cloud Storage: unexpected exception after successfully writing to a Google Cloud Storage object HOT 2
- grpc compatibility issue 2.27.1 HOT 9
- GCP cloud storage downloaded file corruption HOT 4
- Improve Virtual Thread compatibility
- Unable to initiate resumable uploads from java sdk: Cloud storage v2 API. HOT 4
- Unable to Get or Refresh access token from Google Credentials instance in java sdk HOT 1
- Novel transient error introduced between 2.27.1 and 2.30.1? HOT 5
- Add Support for includeFolders option in ListObjects HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java-storage.