-
Notifications
You must be signed in to change notification settings - Fork 87
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
Return packages.json if packages/list.json does not exist #150
base: master
Are you sure you want to change the base?
Conversation
If you go to the drupal 7 repository https://packages.drupal.org/7/ you will find that it does not support the packages/list.json url. In that case we just return the packages.json that was returned. This was making retrieving packages.json from a nexus proxy for drupal 7 return a status 500 error.
In the process to merge the packages json, it was returning a nullpointerexception when the PROVIDERS_KEY was not found. Now it will simply to add the provider to the merged packages json.
@@ -351,7 +351,7 @@ public Content mergePackagesJson(final Repository repository, final List<Payload | |||
for (Payload payload : payloads) { | |||
Map<String, Object> json = parseJson(payload); | |||
Map<String, Object> providers = (Map<String, Object>) json.get(PROVIDERS_KEY); | |||
names.addAll(providers.keySet()); | |||
Optional.ofNullable(providers).ifPresent(pv -> names.addAll(pv.keySet())); |
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.
Why not using a simple old-school but cheap null check instead of creating an Optional instance and an non-static instance lambda?
Optional.ofNullable(providers).ifPresent(pv -> names.addAll(pv.keySet())); | |
if (providers != null) { | |
names.addAll(providers.keySet()); | |
} |
If you insist on functional style, even this would be more efficient:
Optional.ofNullable(providers).map(Map::keySet).ifPresent(names::addAll);
try { | ||
returnedContent = generatePackagesJson(context); | ||
} catch (NullPointerException e) { | ||
returnedContent=content; |
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.
returnedContent=content; | |
returnedContent = content; |
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.
Service the original package.json as cached artifact might work, if the upstream repository uses the same absolute paths, e.g /p2/%package%.json
.
Otherwise this pass-through of the original package.json might lead to broken repositories, e.g. proxying packages.drupal.org with a /files/packages/8/p2/%package%.json
pattern. This path won't resolve on our Nexus instance.
The URLs should be rewritten in any case.
If you go to the drupal 7 repository https://packages.drupal.org/7/ you will find that it does not support the packages/list.json url. In that case we just return the packages.json that was returned. This was making retrieving packages.json from a nexus proxy for drupal 7 return a status 500 error.
(brief, plain english overview of your changes here)
instead of failing a get for packages.json from a proxy which does not support the packages/list.json url, this change will instead return the original information from the target repository packages.json response.
This pull request makes the following changes:
(If there are changes to the UI, please include a screenshot so we
know what to look for!)
no change
(If there are changes to user behavior in general, please make sure to
update the docs, as well)
no change
It relates to the following issue #s:
none