Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S174 : more cleanup #17

Merged
merged 12 commits into from
May 22, 2024
Merged

S174 : more cleanup #17

merged 12 commits into from
May 22, 2024

Conversation

eschultink
Copy link
Member

@eschultink eschultink commented May 17, 2024

Features

  • DI stuff to Dagger 2, if even useful
  • drop unused libs
  • improve perf of serialization, tune

Change implications

  • breaking change to API? no
  • changes dependencies? yes

Copy link
Member

@jlorper jlorper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of suggestions

throw new IOException("Exception while deserilaizing.", e);
public static Object deserialize(byte[] data) throws IOException, ClassNotFoundException {
// Attempt to decompress
try (ByteArrayInputStream byteIn = new ByteArrayInputStream(data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try (ObjectOutputStream objectOut = new ObjectOutputStream(byteOut)) {
objectOut.writeObject(obj);
}
byte[] serializedData = byteOut.toByteArray();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just ask for the size byteOut.size(), doing toByteArray is copying the object into a new array, so consuming x2 memory if it happens to be big.

if (byteOut.size() > MAX) {
// compress
} else {
// return as is
return byteou.toByteArray();
}

public static void inject(String moduleClassFQN, Object injectable) {
ObjectGraph objectGraph = getFromModuleClass(moduleClassFQN);
objectGraph.inject(injectable);
public static void inject(Class<?> componentClass, Object injectable) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not

Suggested change
public static void inject(Class<?> componentClass, Object injectable) {
public static void inject(Class<?> componentClass, Injectable injectable) {

?

So it can fails on compile time ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Injectable is an annotation .. but yeah, will refactor to make things cleaer

@eschultink eschultink merged commit eb96252 into main May 22, 2024
3 checks passed
@eschultink eschultink deleted the s174-more-cleanup branch May 22, 2024 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants