2017-08-30

Weblogic: JAR entry META-INF/adfm.xml not found in _wl_cls_gen.jar

You've just deployed your favorite EAR in a WebLogic successfully, but when you open it, an unfriendly HTTP 500 greets you. This usually happens in development mode.
Error 500--Internal Server Error

oracle.jbo.JboException: JBO-29114 ADFContext is not setup to process messages for this exception. Use the exception stack trace and error code to investigate the root cause of this exception. Root cause error code is JBO-29000. Error message parameters are {0=java.io.FileNotFoundException, 1=JAR entry META-INF/adfm.xml not found in C:\Users\yolo\AppData\Roaming\JDeveloper\system12.2.1.2.42.170105.1224\DefaultDomain\servers\DefaultServer\tmp\_WL_user\OalCdqWorkbench\dfoxis\war\WEB-INF\lib\_wl_cls_gen.jar}
 at oracle.jbo.uicli.mom.CpxUtils.getCpxListFromMetadata(CpxUtils.java:512)
 at oracle.jbo.uicli.mom.JUMetaObjectManager.loadCpx(JUMetaObjectManager.java:915)
 at oracle.adf.model.BindingContext.initialize(BindingContext.java:469)
 at oracle.adf.model.BindingRequestHandler.beginRequest(BindingRequestHandler.java:270)
 at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:196)
 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
 at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:105)
 at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:529)
 at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
 at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:529)
 at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:354)
 at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:232)
 at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
 at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:169)
 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
 at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:141)
 at java.security.AccessController.doPrivileged(Native Method)
 at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
 at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:650)
 at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:124)
 at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:232)
 at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:94)
 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
 at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:248)
 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
 at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:32)
 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
 at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3683)
 at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3649)
 at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:326)
 at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197)
 at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203)
 at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71)
 at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2433)
 at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2281)
 at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2259)
 at weblogic.servlet.internal.ServletRequestImpl.runInternal(ServletRequestImpl.java:1691)
 at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1651)
 at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:270)
 at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
 at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
 at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)
 at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
 at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640)
 at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406)
 at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)
Caused by: java.io.FileNotFoundException: JAR entry META-INF/adfm.xml not found in C:\Users\yolo\AppData\Roaming\JDeveloper\system12.2.1.2.42.170105.1224\DefaultDomain\servers\DefaultServer\tmp\_WL_user\OalCdqWorkbench\dfoxis\war\WEB-INF\lib\_wl_cls_gen.jar
 at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:142)
 at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:150)
 at java.net.URL.openStream(URL.java:1045)
 at oracle.adf.share.common.rc.util.impl.MetadataRegistryImpl.openStream(MetadataRegistryImpl.java:650)
 at oracle.adf.share.common.rc.util.impl.MetadataRegistryImpl.getDomDocument(MetadataRegistryImpl.java:665)
 at oracle.adf.share.common.rc.util.impl.MetadataRegistryImpl.getRegistryPaths(MetadataRegistryImpl.java:247)
 at oracle.adf.share.common.rc.util.impl.MetadataRegistryImpl.visitRegistryPaths(MetadataRegistryImpl.java:160)
 at oracle.adf.share.common.rc.util.impl.MetadataRegistryImpl.visitRegistryPaths(MetadataRegistryImpl.java:116)
 at oracle.jbo.uicli.mom.CpxUtils.getCpxListFromMetadata(CpxUtils.java:491)
 ... 46 more

What to do: Restart WebLogic.

The issue is handled here: https://support.oracle.com/knowledge/Middleware/2244836_1.html
This is a caching issue, so to permanently fix it, upgrade your JDeveloper.

Javascript: Display Image Fetched Through Authenticated REST API

I have a protected REST endpoint in Oracle Content and Experience Cloud, which returns image/png. Let's display it.

var imgUrl = "https://foo.barcloud.com/documents/api/latest/files/FA5A98CDC6482BD3ED6CFEA98CD980E/data/thumbnail";
var user = "foobar";
var pass = "Yolo6969";

// @see https://stackoverflow.com/a/17682424/357403

var xhr = new XMLHttpRequest();

// Success
xhr.addEventListener("load", function __xhrLoaded() {
    var img = document.getElementById('thumbnail');
    // This will create the DataURI for us.
    var URL = window.URL || window.webkitURL;

    switch (this.responseType) {
    case "arraybuffer":
        // createObjectURL only accepts Blob.
        img.src = URL.createObjectURL(new Blob([ this.response ], { type : this.getResponseHeader('Content-Type') }));
        break;
    case "blob":
        img.src = URL.createObjectURL(this.response);
        break;
    default:
        console.error("Unsupported response type: ", this.responseType, " -- expected binary types for image data.");
        break;
    }
});

// Failure
xhr.addEventListener("error", function __xhrFailed() {
    console.log("Request failed.", this);
});

// open (method, uri, isAsync, user, passwd)
xhr.open('GET', imgUrl, true, user, pass);
// Yes, I want to authenticate.
xhr.withCredentials = true;
// I want to authenticate right now.
xhr.setRequestHeader("Authorization", "Basic " + btoa(user + ':' + pass));
// Give me a Blob in the `response` field.
xhr.responseType = "blob";
xhr.overrideMimeType("image/png");
// Execute the action.
xhr.send();

2017-08-23

Java: CORS Filter for Jersey

So you want to add CORS support for your Jersey server.

Add this filter:

package org.example.rest.service.filter;

import java.io.IOException;
import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;

import javax.annotation.Priority;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.Priorities;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.Provider;

import org.glassfish.jersey.server.ExtendedUriInfo;

@Provider
@Priority(Priorities.HEADER_DECORATOR)
public class CORSFilter implements ContainerRequestFilter, ContainerResponseFilter {
 private static final String ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials";
 private static final String ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers";
 private static final String ACCESS_CONTROL_ALLOW_METHODS = "Access-Control-Allow-Methods";
 private static final String ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin";
 private static final String ACCESS_CONTROL_REQUEST_HEADERS = "Access-Control-Request-Headers";
 private static final String AUTHORIZATION = "authorization";
 private static final String ORIGIN = "Origin";

 private static String extractAllowedMethods(final ExtendedUriInfo extendedUriInfo) {
  final Optional<Class<?>> optional = extendedUriInfo.getMatchedRuntimeResources().stream()
    .flatMap(r -> r.getResources().stream()).flatMap(r -> r.getHandlerClasses().stream())
    .filter(r -> r.getPackage().getName().startsWith("org.example.rest.service")).findFirst();

  if (optional.isPresent()) {
   return Arrays.stream(optional.get().getDeclaredMethods())//
     .flatMap(m -> Arrays.stream(m.getAnnotations()))//
     .map(a -> a.annotationType().getAnnotation(javax.ws.rs.HttpMethod.class))//
     .filter(Objects::nonNull)//
     .map(HttpMethod::value)//
     .distinct()//
     .collect(Collectors.joining(", "));
  }
  // Returning OPTIONS is a bit shady, as ACAM is about *real*, actual methods only.
  return "OPTIONS";
 }

 @Context
 private HttpServletRequest request;

 @Context
 private ExtendedUriInfo extendedUriInfo;

 @Override
 public void filter(final ContainerRequestContext requestContext) throws IOException {
  final String origin = requestContext.getHeaderString(ORIGIN);
  if (origin != null && "OPTIONS".equals(requestContext.getMethod())) {
   request.setAttribute(this.getClass().getName(), true);
   requestContext.abortWith(Response.ok("CORS OK, carry on.", MediaType.TEXT_PLAIN_TYPE).build());
  }
 }

 /**
  * @see https://www.w3.org/TR/cors/
  * @see https://jmchung.github.io/blog/2013/08/11/cross-domain-on-jersey-restful-web-services/
  * @see https://solutionsisee.wordpress.com/2016/06/30/adding-cors-support-in-jersey-server/
  */
 @Override
 public void filter(final ContainerRequestContext requestContext, final ContainerResponseContext responseContext)
   throws IOException {

  final MultivaluedMap<String, Object> responseHeaders = responseContext.getHeaders();
  final String origin = requestContext.getHeaderString(ORIGIN);

  if (origin != null) {
   // The presence of the Origin header marks a CORS request.
   responseHeaders.add(ACCESS_CONTROL_ALLOW_ORIGIN, origin);
   responseHeaders.add(ACCESS_CONTROL_ALLOW_METHODS, extractAllowedMethods(extendedUriInfo));
   responseHeaders.add(ACCESS_CONTROL_ALLOW_HEADERS, AUTHORIZATION + ", X-Requested-With, Content-Type");
   if (requestContext.getHeaderString(ACCESS_CONTROL_REQUEST_HEADERS) != null) {
    responseHeaders.add(ACCESS_CONTROL_ALLOW_CREDENTIALS, requestContext
      .getHeaderString(ACCESS_CONTROL_REQUEST_HEADERS).toLowerCase().contains(AUTHORIZATION));
   }
  }

  if (request.getAttribute(this.getClass().getName()) != null) {
   // We are in a CORS Preflight answer, fast tracked. The entity (== response body) is not
   // relevant.
  }
 }
}

It is almost implementation agnostic, except for the ExtendedUriInfo.

2017-07-05

Maven: Using Oracle Archetypes with Maven in Eclipse


  1. Go here: https://community.oracle.com/docs/DOC-894569
  2. Download this file: https://maven.oracle.com/archetype-catalog.xml
    1. It will ask for your OTN login, of course.
    2. If you don't download it, you will not be able to use it.
  3. During archetype selection, click Configure... next to the Catalog drop-down.
  4. Add Local Catalog...
    1. Adding a remote catalog is not working because of the HTTP Basic auth.
  5. Choose the recently downloaded file.
  6. Do the next-next-finish magic.
  7. Voilá.
You might also need this as a reference: Configuring the Oracle Maven Repository

For the exact version of the archetype, take a ook inside: https://www.oracle.com/content/secure/maven/content/com/oracle/weblogic/archetype/basic-webapp/maven-metadata.xml

2017-06-06

Oracle: Uninstall JDeveloper

Oracle JDeveloper does not have a link to the uninstaller in the Start Menu, nor has an entry in the Programs and Features inside Control Panel. Also, they call it deinstallation, not uninstallation...
But how then?
There is a deinstall.cmd in C:\Oracle\Middleware\Oracle_Home\oui\bin (your ORACLE_HOME may vary). Execute that, and follow the GUI's instructions.

2017-05-24

X as a Service

The SPI Model

  • SaaS – Software as a Service → provisioned UI &| [any kind of] API access (eg. hosted webapps [eg. webshops, salesforce, github, Akamai CDN, maybe even wikipedia counts as one])
  • PaaS – Platform as a Service → provisioned software ecosystem (eg. Hadoop [eg. Amazon EMR], RDBMS [eg. Amazon RDS*], NoSQL clusters, WebLogics, Glassfishes, Tomcats)
  • IaaS – Infrastructure as a Service → provisioned compute instances (eg. VM, storage [eg. Amazon EC2, S3], maybe even a leased HW in a colocation hosting site counts as one)

2017-04-18

Fallacy: Process as Proxy

https://www.sec.gov/Archives/edgar/data/1018724/000119312517120198/d373368dex991.htm

Resist Proxies

As companies get larger and more complex, there’s a tendency to manage to proxies. This comes in many shapes and sizes, and it’s dangerous, subtle, and very Day 2.

A common example is process as proxy. Good process serves you so you can serve customers. But if you’re not watchful, the process can become the thing. This can happen very easily in large organizations. The process becomes the proxy for the result you want. You stop looking at outcomes and just make sure you’re doing the process right. Gulp. It’s not that rare to hear a junior leader defend a bad outcome with something like, “Well, we followed the process.” A more experienced leader will use it as an opportunity to investigate and improve the process. The process is not the thing. It’s always worth asking, do we own the process or does the process own us?

2017-03-23

Java: Silence Eclipse's Null Type Safety Warnings Where It Shouldn't

So you just enabled "Null analysis" in Eclipse, and set a reasonable NonNull annotation to confom (ie. javax.validation.constraints.NotNull), also started annotating the relevant methods with it.

But.
When using the new Java 8 Streams API, Eclipse warns inside the functions you toss in, even if you've filtered out the null ones.

I'll give you an example:
// ...inside the Foo class...
public Foo(@NotNull final Bar bar) {
        this.bar = Objects.requireNonNull(bar, "Shame...");
}
// ...inside somewhere completely unrelated...
public Optional<Foo> getFoobarizedBarBaz() {
        return Optional.ofNullable(
                fooService.getBar()
                        .stream()
                                .filter(Objects::nonNull) // yeah, so no nulls, plz
                                .map(bar -> new Foo(bar /* Oh no, yellow underline*/, someLocalValue)
                                .findAny());
}

But oh, the "bar" is underlined, stating "Null type safety: The expression of type 'Bar' needs unchecked conversion to conform to '@NotNull Bar'"...

If only there were a way to resolve that...wait, there is! We can set the type of the formal parameters inside the lambda expression!
// ...inside somewhere completely unrelated...
public Optional<Foo> getFoobarizedBarBaz() {
        return Optional.ofNullable(
                fooService.getBar()
                        .stream()
                                .filter(Objects::nonNull)
                                .map((@NotNull Bar bar) -> new Foo(bar, someLocalValue)
                                .findAny());
}

Formal parameters. PARAMETERS.
@NotNull's @Target annotation includes PARAMETER.
Even it's comment states: "Formal parameter declaration".

Win.

2017-03-17

hosts: Blocking noxious sites effectively

Years ago I found this cool website: http://someonewhocares.org/hosts/

It blocks a lot of sites you don't normally want to visit :)

Also, I have a Hungary-specific compilation of anti-science / russian propaganda / simply dumb sites (and a few USA-specific ones) you don't want to stumble upon:

#<hu-russian-propaganda>
127.0.0.1 888.hu
127.0.0.1 adatlistazo.hu
127.0.0.1 aktiv-blog.net
127.0.0.1 aktivblog.net
127.0.0.1 atomenergiainfo.hu # powered by rosatom :)
127.0.0.1 balrad.com
127.0.0.1 bejegyzes.com
127.0.0.1 civilkontroll.com
127.0.0.1 debmedia.hu
127.0.0.1 elkepeszto.net
127.0.0.1 hidfo.net
127.0.0.1 hidfo.ru
127.0.0.1 hir.club
127.0.0.1 hirado.top
127.0.0.1 hirarena.eu
127.0.0.1 hircentrum.top
127.0.0.1 hirek.in
127.0.0.1 hirek.top
127.0.0.1 hirekonline.net
127.0.0.1 hirexpressz.top
127.0.0.1 hirhatar.hu
127.0.0.1 hirkert.info
127.0.0.1 hirkozpont.eu
127.0.0.1 hirlistazo.com
127.0.0.1 hirma.info
127.0.0.1 hirmagazin.eu
127.0.0.1 hironline.club
127.0.0.1 hirportal.info
127.0.0.1 hirtop.in
127.0.0.1 hirtrafik.top
127.0.0.1 hirvilag.eu
127.0.0.1 hungarian.ruvr.ru
127.0.0.1 hunhir.hu
127.0.0.1 hunhir.info
127.0.0.1 hunhonlap.hu
127.0.0.1 hunsor.se
127.0.0.1 huntv.info
127.0.0.1 impulzus.net
127.0.0.1 internetfigyelo.wordpress.com
127.0.0.1 jovonk.info
127.0.0.1 kho.jobbikhosting.com
127.0.0.1 kitartas.net
127.0.0.1 kulfoldiapro.com
127.0.0.1 kuruc.info
127.0.0.1 legfrissebb.info
127.0.0.1 lovasistvan.hu
127.0.0.1 ma.hu
127.0.0.1 magyarifjak.org
127.0.0.1 magyarmegmaradasert.hu
127.0.0.1 magyarno.com
127.0.0.1 magyartudat.com
127.0.0.1 maivalosag.com
127.0.0.1 meteon.org
127.0.0.1 mindenegyben-blog.net
127.0.0.1 mindenegyben.net
127.0.0.1 mindenegybenblog.com
127.0.0.1 mokazona.eu
127.0.0.1 napihirozon.eu
127.0.0.1 napimigrans.com
127.0.0.1 nemadomahazamat.hu
127.0.0.1 nemzeti.net
127.0.0.1 nemzetiarcvonal.net
127.0.0.1 nemzetibulvar.hu
127.0.0.1 nemzetihirhalo.hu
127.0.0.1 netbulvar.com
127.0.0.1 netbulvar.eu
127.0.0.1 netceleb.eu
127.0.0.1 netceleb.hu
127.0.0.1 nethir.com
127.0.0.1 orientalista.hu
127.0.0.1 oroszhirek.hu
127.0.0.1 paxhungarica.org
127.0.0.1 rapidpress.info
127.0.0.1 realzoldek.hu
127.0.0.1 simsim.eu
127.0.0.1 sokkaljobb.hu
127.0.0.1 szabadriport.wordpress.com
127.0.0.1 szentkoronaradio.hu
127.0.0.1 thenews.hu
127.0.0.1 titkolthirek.hu
127.0.0.1 totalcar.top
127.0.0.1 tvhir.com
127.0.0.1 videohirek.com
127.0.0.1 vilaghalo.info
127.0.0.1 vilagom.hu
127.0.0.1 adatlistazo.hu
127.0.0.1 hidfo.net
127.0.0.1 xcore.in
#</hu-russian-propaganda>
 
#<hu-conteo-sites>
## These are Hungarian sites spreading bullshit (typical antivaxxer, anti-science, and/or fake news sites).
127.0.0.1 2perc.info
127.0.0.1 aktiv-hir.net
127.0.0.1 aktivhir.net
127.0.0.1 atomenergiainfo.hu
127.0.0.1 avilagtitkai.com
127.0.0.1 best-hir.com
127.0.0.1 bizony.eu
127.0.0.1 csucshatas.eu
127.0.0.1 csumida.com
127.0.0.1 dekutya.com
127.0.0.1 egeszsegmindenkinek.hu
127.0.0.1 epic-info.com
127.0.0.1 ez-zsir.net
127.0.0.1 ezt-figyeld.com
127.0.0.1 filmtar.in
127.0.0.1 frenetikus.com
127.0.0.1 hirado-online.net
127.0.0.1 hirexpressz.top
127.0.0.1 hirkert.info
127.0.0.1 hirnap.info
127.0.0.1 hirtop.in
127.0.0.1 husospizza.com
127.0.0.1 impulzus.net
127.0.0.1 index-video.com
127.0.0.1 magyarkozosseg.net
127.0.0.1 mindenegyben-blog.net
127.0.0.1 mindenegybenblog.hu
127.0.0.1 mindenegyhelyen.info
127.0.0.1 napi-hir.net
127.0.0.1 napiszarka.com
127.0.0.1 nemkutya.com
127.0.0.1 netextra.hu
127.0.0.1 nyaralok.net
127.0.0.1 origo-hir.net
127.0.0.1 origo-hirek.net
127.0.0.1 origo-online.info
127.0.0.1 origo-online.net
127.0.0.1 origoblog.net
127.0.0.1 origohir.net
127.0.0.1 origoonline.net
127.0.0.1 szupcsi.eu
127.0.0.1 tudnodkel.blogspot.com
127.0.0.1 tudnodkell.blogspot.com
127.0.0.1 tutihirek.com
127.0.0.1 vakarek.info
127.0.0.1 valoshirek.top
127.0.0.1 vattacukor.net
127.0.0.1 video-perc.net
127.0.0.1 hirnap.info
127.0.0.1 video-perc.net
#</hu-conteo-sites>
 
#<us-fake-news-sites>
127.0.0.1 100percentfedup.com
127.0.0.1 21stcenturywire.com
127.0.0.1 70news.wordpress.com
127.0.0.1 abcnews.com.co
127.0.0.1 activistpost.com
127.0.0.1 addictinginfo.org
127.0.0.1 americannewsx.com
127.0.0.1 americannews.com
127.0.0.1 anonnews.co
127.0.0.1 associatedmediacoverage.com
127.0.0.1 thebostontribune.com
127.0.0.1 beforeitsnews.com
127.0.0.1 beingliberal.org
127.0.0.1 bigamericannews.com
127.0.0.1 bigpzone.com
127.0.0.1 bipartisanreport.com
127.0.0.1 bizpacreview.com
127.0.0.1 bluenationreview.com
127.0.0.1 breitbart.com
127.0.0.1 cap-news.com
127.0.0.1 christwire.org
127.0.0.1 chronicle.su
127.0.0.1 civictribune.com
127.0.0.1 clickhole.com
127.0.0.1 coasttocoastam.com
127.0.0.1 collective-evolution.com
127.0.0.1 consciouslifenews.com
127.0.0.1 conservativeoutfitters.com
127.0.0.1 wideawakeamerica.com
127.0.0.1 countdowntozerotime.com
127.0.0.1 counterpsyops.com
127.0.0.1 creambmp.com
127.0.0.1 crooksandliars.com
127.0.0.1 dcclothesline.com
127.0.0.1 dcgazette.com
127.0.0.1 dailywire.com
127.0.0.1 dailybuzzlive.com
127.0.0.1 dailycurrant.com
127.0.0.1 derfmagazine.com
127.0.0.1 disclose.tv
127.0.0.1 drudgereport.com.co
127.0.0.1 duffleblog.com
127.0.0.1 duhprogressive.com
127.0.0.1 embols.com
127.0.0.1 empireherald.com
127.0.0.1 empirenews.net
127.0.0.1 empirenews.com
127.0.0.1 endingthefed.com
127.0.0.1 enduringvision.com
127.0.0.1 fprnradio.com
127.0.0.1 geoengineeringwatch.org
127.0.0.1 globalresearch.ca
127.0.0.1 govtslaves.info
127.0.0.1 gulagbound.com
127.0.0.1 hangthebankers.com
127.0.0.1 humansarefree.com
127.0.0.1 huzlers.com
127.0.0.1 ijr.com
127.0.0.1 ifyouonlynews.com
127.0.0.1 indecisionforever.com
127.0.0.1 infowars.com
127.0.0.1 inquisitr.com
127.0.0.1 intellihub.com
127.0.0.1 jonesreport.com
127.0.0.1 lewrockwell.com
127.0.0.1 liberalamerica.org
127.0.0.1 libertymovementradio.com
127.0.0.1 libertytalk.fm
127.0.0.1 libertyunyielding.com
127.0.0.1 libertyvideos.org
127.0.0.1 msnbc.com.co
127.0.0.1 msnbc.website
127.0.0.1 mediamass.net
127.0.0.1 megynkelly.us
127.0.0.1 ncscooper.com
127.0.0.1 nahadaily.com
127.0.0.1 nationalreport.net
127.0.0.1 naturalnews.com
127.0.0.1 newcenturytimes.com
127.0.0.1 newsexaminer.com
127.0.0.1 news-hound.com
127.0.0.1 newsbiscuit.com
127.0.0.1 newsbuzzdaily.com
127.0.0.1 newsmutiny.com
127.0.0.1 newswire-24.com
127.0.0.1 newslo.com
127.0.0.1 newswatch28.com
127.0.0.1 newswatch33.com
127.0.0.1 nodisinfo.com
127.0.0.1 now8news.com
127.0.0.1 nowtheendbegins.com
127.0.0.1 occupydemocrats.com
127.0.0.1 pakalertpress.com
127.0.0.1 politicalblindspot.com
127.0.0.1 politicalears.com
127.0.0.1 politicususa.com
127.0.0.1 prisonplanet.com
127.0.0.1 prisonplanet.tv
127.0.0.1 private-eye.co.uk
127.0.0.1 projectveritas.com
127.0.0.1 react365.com
127.0.0.1 realfarmacy.com
127.0.0.1 realnewsrightnow.com
127.0.0.1 redstate.com
127.0.0.1 redflagnews.com
127.0.0.1 reductress.com
127.0.0.1 rilenews.com
127.0.0.1 satiratribune.com
127.0.0.1 sprotspickle.com
127.0.0.1 theblaze.com
127.0.0.1 thefreethoughtproject.com
127.0.0.1 other98.com
127.0.0.1 thereporter.com
127.0.0.1 thedailysheeple.com
127.0.0.1 thenewsnerd.com
127.0.0.1 therundownlive.com
127.0.0.1 theuspatriot.com
127.0.0.1 truthfrequencyradio.com
127.0.0.1 twitchy.com
127.0.0.1 usuncut.com
127.0.0.1 usasupreme.com
127.0.0.1 unconfirmedsources.com
127.0.0.1 veteranstoday.com
127.0.0.1 wakingupwisconsin.com
127.0.0.1 wakingtimes.com
127.0.0.1 wideawakeamerica.com
127.0.0.1 winningdemocrats.com
127.0.0.1 witscience.org
127.0.0.1 wnd.com
127.0.0.1 worldnewsdailyreport.com
127.0.0.1 worldtruth.tv
127.0.0.1 zerohedge.com
#</us-fake-news-sites>

Do not forget to regularly update :)

2017-01-10

Java: About returning Optional and Collections

Copy-paste post follows.
Of course, people will do what they want. But we did have a clear intention when adding this feature, and it was not to be a general purpose Maybe or Some type, as much as many people would have liked us to do so. Our intention was to provide a limited mechanism for library method return types where there needed to be a clear way to represent "no result", and using null for such was overwhelmingly likely to cause errors.

For example, you probably should never use it for something that returns an array of results, or a list of results; instead return an empty array or list. You should almost never use it as a field of something or a method parameter.

I think routinely using it as a return value for getters would definitely be over-use.

There's nothing wrong with Optional that it should be avoided, it's just not what many people wish it were, and accordingly we were fairly concerned about the risk of zealous over-use.

(Public service announcement: NEVER call Optional.get unless you can prove it will never be null; instead use one of the safe methods like orElse or ifPresent. In retrospect, we should have called get something like getOrElseThrowNoSuchElementException or something that made it far clearer that this was a highly dangerous method that undermined the whole purpose of Optional in the first place. Lesson learned.)

Source: http://stackoverflow.com/a/26328555/357403

The Lord has been spoken.