-
Notifications
You must be signed in to change notification settings - Fork 23
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
build: Added configurations to apply constraints to dependencies resolves
#134
#159
base: develop
Are you sure you want to change the base?
Changes from all commits
43923eb
8470756
d381426
8c92053
2a2ec8c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
package org.terasology.gestalt.assets; | ||
|
||
|
||
import android.support.annotation.Nullable; | ||
|
||
import com.google.common.base.Function; | ||
|
@@ -45,16 +46,17 @@ | |
import java.lang.ref.ReferenceQueue; | ||
import java.lang.ref.WeakReference; | ||
import java.lang.reflect.Type; | ||
import java.security.AccessController; | ||
import java.security.PrivilegedActionException; | ||
import java.security.PrivilegedExceptionAction; | ||
|
||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.concurrent.Semaphore; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* AssetType manages all assets of a particular type/class. It provides the ability to resolve and load assets by Urn, and caches assets so that there is only | ||
* a single instance of a given asset shared by all users. | ||
|
@@ -131,7 +133,7 @@ public synchronized void close() { | |
/** | ||
* Disposes any assets queued for disposal. This occurs if an asset is no longer referenced by anything. | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
//@SuppressWarnings("unchecked") | ||
public void processDisposal() { | ||
Reference<? extends Asset<U>> ref = disposalQueue.poll(); | ||
while (ref != null) { | ||
|
@@ -298,7 +300,7 @@ synchronized void registerAsset(Asset<U> asset, DisposalHook disposer) { | |
} | ||
|
||
/** | ||
* Creates and returns an instance of an asset, if possible. The following methods are used to create the copy, in order, with the first technique to succeeed used: | ||
* Creates and returns an instance of an asset, if possible. The following methods are used to create the copy, in order, with the first technique to succeed used: | ||
Thedrogon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* <ol> | ||
* <li>Delegate to the parent asset to create the copy</li> | ||
* <li>Loads the AssetData of the parent asset and create a new instance from that</li> | ||
|
@@ -307,7 +309,7 @@ synchronized void registerAsset(Asset<U> asset, DisposalHook disposer) { | |
* @param urn The urn of the asset to create an instance of | ||
* @return An instance of the desired asset | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
// @SuppressWarnings("unchecked") | ||
public Optional<T> getInstanceAsset(ResourceUrn urn) { | ||
Optional<? extends T> parentAsset = getAsset(urn.getParentUrn()); | ||
if (parentAsset.isPresent()) { | ||
|
@@ -328,16 +330,16 @@ Optional<T> createInstance(Asset<U> asset) { | |
Optional<? extends Asset<U>> result = asset.createCopy(asset.getUrn().getInstanceUrn()); | ||
if (!result.isPresent()) { | ||
try { | ||
return AccessController.doPrivileged((PrivilegedExceptionAction<Optional<T>>) () -> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Despite being deprecated, I'm afraid that for the time being we do still need to use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then for the requirement I will revert them in the PR. |
||
|
||
for (AssetDataProducer<U> producer : producers) { | ||
Optional<U> data = producer.getAssetData(asset.getUrn()); | ||
if (data.isPresent()) { | ||
return Optional.of(loadAsset(asset.getUrn().getInstanceUrn(), data.get())); | ||
} | ||
} | ||
return Optional.ofNullable(assetClass.cast(result.get())); | ||
}); | ||
} catch (PrivilegedActionException e) { | ||
|
||
} catch (Exception e) { | ||
logger.error("Failed to load asset '" + asset.getUrn().getInstanceUrn() + "'", e.getCause()); | ||
} | ||
} | ||
|
@@ -355,16 +357,16 @@ public Optional<T> reload(ResourceUrn urn) { | |
Preconditions.checkArgument(!urn.isInstance(), "Cannot reload an asset instance urn"); | ||
ResourceUrn redirectUrn = followRedirects(urn); | ||
try { | ||
return AccessController.doPrivileged((PrivilegedExceptionAction<Optional<T>>) () -> { | ||
for (AssetDataProducer<U> producer : producers) { | ||
Optional<U> data = producer.getAssetData(redirectUrn); | ||
if (data.isPresent()) { | ||
return Optional.of(loadAsset(redirectUrn, data.get())); | ||
} | ||
} | ||
return Optional.ofNullable(loadedAssets.get(redirectUrn)); | ||
}); | ||
} catch (PrivilegedActionException e) { | ||
|
||
} catch (Exception e) { | ||
if (redirectUrn.equals(urn)) { | ||
logger.error("Failed to load asset '{}'", redirectUrn, e.getCause()); | ||
} else { | ||
|
@@ -484,7 +486,7 @@ public Set<ResourceUrn> resolve(String urn, Name moduleContext) { | |
return Sets.newLinkedHashSet(Collections2.transform(possibleModules, new Function<Name, ResourceUrn>() { | ||
@Nullable | ||
@Override | ||
public ResourceUrn apply(Name input) { | ||
public ResourceUrn apply(@Nonnull Name input) { | ||
return new ResourceUrn(input, resourceName, fragmentName, instance); | ||
} | ||
})); | ||
|
@@ -601,7 +603,7 @@ public boolean equals(Object obj) { | |
return true; | ||
} | ||
if (obj instanceof AssetType) { | ||
AssetType other = (AssetType) obj; | ||
AssetType<?, ?> other = (AssetType<?, ?>) obj; | ||
return assetClass.equals(other.assetClass); | ||
} | ||
return false; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can either remove those suppressions or leave them be but commenting them out like that in committed code is rather messy.